How to write Greasemonkey scripts

last updated in Categories Links, Mozilla, News

Greasemonkey is a Mozilla Firefox extension that allows users to install scripts that make on-the-fly changes to specific web pages. Greasemonkey can be used for adding new functionality to pages.


Most Greasemonkey user scripts are written by hand, using site-specific JavaScript code which manipulates the contents of a webpage using the Document Object Model interface

Dive Into Greasemonkey is a book about programming with Greasemonkey, a Firefox extension for customizing web pages. According to this book “Greasemonkey is a Firefox extension that allows you to write scripts that alter the web pages you visit. You can use it to make a web site more readable or more usable. You can fix rendering bugs that the site owner can’t be bothered to fix themselves. You can alter pages so they work better with assistive technologies that speak a web page out loud or convert it to Braille. You can even automatically retrieve data from other sites to make two sites more interconnected.”

The book covers installation of Greasemonkey to various Advanced Topics. I find it very helpful. This book, its sample code are under terms of the GNU General Public License.
=> Download PDF Version (167K)

=> Download HTML Version (253K)

=> Read online.


Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

11 comment

  1. Yea greasemonkey is pretty awesome in the right hands. But you put it in the hands of Jason Calacanis it can be downright eveil. Its no secret I can’t stand jason calacanis. I rant about him all the time on < DELETED dead url by admin >

  2. If you install IE7 Pro which is an add on for Internet Explore, you can also get greasemonkey scripts for IE7.
    Besides you get a lot other, like adblocker and so on.

    // Heinz The Man

  3. In section 2.3, the reason the “bad example” doesn’t work is because it passes a dynamic javascript snippet instead of the function itself. In other words, instead of using the anonymous function, it can as well be written as “window.setTimeout(helloworld, 1000)”. BTW, the timeout is in milliseconds, so it should be 1000, not 60.

    Have a question? Post it on our forum!