To all the people programming userscripts: How?

Sorry if this is a little off-topic! I’m an incoming college computer science student and only have a fundamental knowledge of Java (read: I don’t have any real experience building programs or other real-world applications). I would like to learn how to make scripts, but I have no idea where to start :sweat_smile: I thought that since there appear to be many programmers in this forum, I should just give it a go. does anybody have any pointers on where to start learning to do this? I’m assuming these are mostly programmed in Python (correct me if I’m wrong).


Quick reply: They are programmed in Javascript actually. I would recommend looking at other small scripts and try to follow their flow.


I don’t think you will have trouble to get started, once you got the basics you just need a good idea for a script.

First you need to understand what is happening. The basis is a browser extension (for example one called Tampermonkey) that will execute your script. If you load a web page, Tampermonkey will look at a list of URLs that it should modify (so-called includes). Every script must mention what pages it works on.

Then, every script that matches a page (say is executed (edit: to be clear, the browser executes it, Tampermonkey basically just appends the scripts to the loaded page) after the page loaded, in the context of the DOM, so you can access the content (“give me all <h1> headings”, etc.) and modify it. Of course you can do most things Javascript can do, so the logic can be sophisticated, but in the end you just do stuff and edit the page itself to show the results to the user.

I suggest you look at a very simple script (say Wanikani Golden Burn - Source code *), copy/paste it into a new script in Tampermonkey (it has an editor), and then go from there. You can look what should go into the script header by searching for either Tampermonkey of Greasemonkey (the predecessor who defined the format). Of course you should also learn Javascript and learn how to use the developer tools to analyze pages (like “how can I select that second-last section there to modify it, by id or class, or …”)

* [That code creates an anonymous function that is directly executed, basically anything inside that function(gobj) will be executed at @run-at document-end. It just adds a CSS style to WK and the forums.]


This is a quick and easy read on how to get started with them and what exactly is happening from ground zero: Applying JavaScript: User Scripts


I didn’t have any JS knowledge when I started making scripts either. The only experience I had was with simpler Python programming. What I did to start was look at the code of the scripts I had installed, to understand the syntax and how things worked. From there it’s pretty easy to Google your way.


Learning to make userscripts is like learning another language. :slight_smile: It’s a lot of fun.


If you have a little bit of money like around, Udacity is good too. But there are loads of free resources if you’re okay with less structure :smile:


I’m an incoming computer science undergraduate too! Always been interested with how the others in the community write userscripts. Great to know that someone else is in a similar position as I am :smile:

1 Like