What are user scripts?

I see people talking about it in the community but I have no idea what it is.

1 Like

I had never heard of them before I started using WaniKani either. ^^ These are programs (? not sure if that’s technically the correct term - not a programmer over here) coded/designed by members of the community. Basically, they are things you can install in your browser to customize your WaniKani experience. These customizations can be purely cosmetic (i.e. changing the fonts/screen color), or they can change some of the functionalities of WaniKani. For example, a lot of people use the override script so that they have the ability to mark answers correct even when WaniKani marks them wrong.

There’s a lot more information in the post linked below, including a guide on how to install them and a list of the different scripts available/what they can do:

I hope this is kind of helpful at least. :sweat_smile: I’m by no means an expert, and I’m sure there are a lot of people on here who would be able to give you a more technical explanation of what they are/how they work.

3 Likes

On any web site, there three major components:

  • HTML: The actual content of the web page
  • Style Sheets (CSS): Describes how to make the HTML look (colour, borders, what gets drawn where)
  • JavaScript: Lets a web page do interesting and interactive things (the fiddly bits).

Userscripts are nothing more than JavaScript that is added onto the web page to change existing functions, or to add new ones. If you aren’t technically inclined, think of userscripts as extra fiddly bits to expand what a web site can do. Just be careful that the scripts you use are either trusted by the community, or you are absolutely sure that you know what they do by reading and understanding the code.

1 Like

You can enhance a website using these user scripts. They operate on your browser (meaning your changes can only be seen by you on that browser). These user scripts use a language called JavaScript.

On WK, these user scripts can do quite a lot because WK provides its users with the so-called API (application programming interface). This is basically just plain text files containing various information (your user name, your level, how many radicals in your review pile, etc.) that can be read by the user scripts.

User scripts can then use this information to enhance your user experience. For example the Ultimate Timeline user script shows bar graphs of your next review sessions for the next X days.

1 Like

What is a userscript?

Let’s look at how web pages work first. Originally web pages were made of HTML documents, these described what to show on the screen and any styling on the page (there’s other components as well, but I’m ignoring them for simplicity). Modern web pages also use JavaScript, a programming language which allows you to make web pages act much more like programs that you would run on your computer. JavaScript interacts with the HTML and can change what you show on the screen, change the text of things, send information back to the server, request more information from the server, and perform calculations.

When you go to a website in your browser, the server sends your computer the information that is needed to display and interact with that page, it sends the HTML and JavaScript files, and then the browser does the work of rendering it and allowing you to interact with it. One interesting result of this is that you can actually look at the HTML and JavaScript files that the server sends. In addition, you can actually edit them, and your browser will update accordingly. Now you are only making edits locally on your machine, and no one else who uses the website will see them. It’s kind of like if you’re reading a recipe book and you decide to change an ingredient, it only changes for you, not everyone else who makes the recipe.

Now we can take this idea even further. Since you can manually edit these files, and JavaScript can also edit these files, you can run JavaScript locally that edits the files and makes the web app behave differently. These are what user scripts are. You have to download them and install them locally because they don’t affect anyone else’s experience, just your own. They’re also not provided by the good folks at Tofugu, so you don’t get them by default when you navigate to WaniKani in your browser.

So what can a user script do? Since you can update the HTML on a web page, it allows you to add or remove a section from the page, you see this in the ultimate timeline script. Since JavaScript can interact with the server, it allows you to request more or different information than the page would normally do. This is what the reorder script does. Since you can do calculations or interact with other JavaScript, you can change how the JavaScript on the site works, this is what the answer override script does, it catches your wrong answers, and gives you a chance to ignore them before the data is sent to the server.

Like with the cooking example above, you can do great things with userscripts. You can read comments about a recipe that might suggest adding thyme in addition to basil to get a deeper flavor, but there are also scripts that can break the functionality of a website. Imagine if you were making a cake and you found a comment (userscript) that said “hey, I made this cake, and it was so much better when I replaced all of the sugar with salt!” that might not give you the best results, but you’re making the cake, so nothing is there to stop you. Most of the really popular user scripts you see people talking about have been vetted by other members of the community, but you should go into it knowing that not everything is perfect.

1 Like

Also, at least for the case of the forums here on Discourse, @Isila, there are a few “Stylish” addons that you can get to change the appearance of the forum, using CSS. Sometimes we still refer to them as userscripts as well, even though that is not technically correct. Instead, they’re in reality more of a SKIN being placed on top of the website, like you painted over it all with a colour. Functionality does not change (although some could argue it does, as some Stylish designs involve moving bits of the website around - so the layout is also different), but appearance does.

A userfriendly tl;dr - those are addons/plugins to enhance the WK functionality and are made by the community.

I had heard those being called “userstyles”.

That would definitely be correct. I’ve heard (and used) both, (even knowing “script” is incorrect). ^^;

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.