Sharing Our Passion for Technology
& Continuous Learning
Greasemonkey
Greasemonkey is an extension for Firefox that leverages javascript to modify the look and functionality of a page. At first glance this tool looks like a neat toy. However, this tool came in quite handy at one of our partners recently.
Our partner was tracking their daily status on a whiteboard in a conference room. A corporate memo was sent out banning the exclusive use of whiteboards for teams. As a result we turned to our web-based tracking tool. Unfortunately their whiteboard equivalent was clunky and inadequate. I spent a few hours putting together a Greasemonkey script that altered the look of this page to mimic our old whiteboard. These changes helped ease this transition.
Let's walk through a simple example to change the behavior of the base Google search page.
- Download and install Greasemonkey from https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/
- Navigate to www.google.com
- Tools - > Greasemonkey -> New User Script...
- Enter a name
- Enter a namespace (This is provided so your scripts do not clash with others)
- Verify that the Includes contain 'http://www.google.com/'
- A new js file will open in your default text editor.
- The script will contain a comment that reflects the values that you entered
- Add the following code
- GM_addStyle is method provided by the Greasemonkey API.(http://wiki.greasespot.net/Greasemonkey_Manual:API)
- Save the script and refresh 'www.google.com'
- You should see grease monkeys all over the page.
- Now add the following code
- Save the script and refresh 'www.google.com'
- You should see an alert box with the text above.
GM_addStyle("\
body{\
background-image:url('http://upload.wikimedia.org/wikipedia/en/d/d3/Gm_icon.png');\
}\
");
alert("I have been modified by Greasemonkey.");