Intro

Is something annoying you about your favorite web site? Don't like something about the layout, the controls, some annoying box elements with uselless information, or something?

You can fix it, at least for yourself, without having to hack the web server by using Tampermonkey, a user script extension for almost every web browser out there.

User scripts are also called Greasemonkey scripts because the first browser extension to support them was Greasemonkey for Firefox. You can still get Greasemonkey, but I like Tampermonkey better because it seems to be getting work done on it lately and there's a version of it for almost every browser, even Opera.

Do It

First, install the Tampermonkey extension. Then, get a sense of how it works by visiting one or more of these repositories:

Treat these sites as though they contain malware.

Browse the scripts others have written. Search for the name of the web site that's annoying you to see if anyone else has written a script for it. You might find something you can customize, or you might have to start from scratch.

Warning! Installing user scripts from others can be very dangerous since they can pretty much do anything such as steal your credit card numbers. Never install a script unless you read the whole thing yourself, understand what it does, and are absolutely sure that you know it isn't doing anything suspicious. Never install a script that contains minified or obfuscated code that you can't read! You have been warned!

Write your own script please

Well, I hope that got your attention. Really the best thing to do is write your own script. That way, unless you have dissociative personality disorder and one of your alts is an evil hacker, you can be pretty sure that you aren't running a malicious script.

The reference docs on writing scripts for Tampermonkey are here. Then take a look at a simple example script like this one to see what sort of header information you need.

Tampermonkey has it's own built-in editor. Just hit the Tampermonkey button and select Dashboard.

To get a new script, hit the little + tab in the upper right. You'll get a nice template with an IIFE (Immediately Invoked Function Expression) that you should put all your code in to avoid global namespace pollution.

Your script can be as simple or complicated as you want.

The Greasemonkey Hacks book is free online. Typical stuff that you'll want to do is covered here.

A DOM reference will come in handy.

Conclusion

Someone wrote a nicer guide than mine which contains screenshots. It might be helpful too!

Have fun!


22,958 1 2