January 02, 2011
Lately I’ve been hacking around with userscripts. Those scripts are JavaScript files that can enhance the experience of a user on certain websites. Here’s a list to get you to start thinking:
Make a site more readable by changing the color of the text. Add support for keyboard shortcuts. Remove really annoying ads. Of course you could think of many more things, the list is literately endless.
My most popular script so far is an ad remover for thepiratebay.org. The first version of the script was launched on the 5th of November 2010 and has had 320 downloads so far.
When looking at talks on ted.com, the default flash player always annoyed me. The full screen button didn’t work and seeking through the video was buggy. Apart from that, when you go full screen, you still had the flash player controls on the top and bottom of the screen. As an alternative, I wanted to use the open-source JW Player.
mflow.com is a great online music player for discovering new songs. The script ads some basic keyboard shortcuts to pause/resume a song or go to the next one. It was pretty straightforward to do, since I was able to access their JavaScript library.
You can find some of the other scripts I wrote and a more up to date list on my userscripts.org profile page.
If you want to make sure that your script also runs in Google Chrome, do the following:
Next to the @include attribute, also use the @match attribute. This will make sure that the user who install the userscript will get an appropriate message:
Most of the time you don’t need this, but if you do, create a script element and append it to the head or body.
Greasemonkey allows you to access global JavaScript variables through this variable, but google chrome doesn’t. You can find a workaround in my mflow userscript.
You can find more information about userscripts in google chrome on the chromium userscripts page.