Circuits Of Imagination

Greasemonkey 101

15 Feb 2011

So I’m reading InfoWorld the other day and on the side of the page ther is that annoying “Share This” toolbar. Now I have AdBlock installed but it skipped this one for some reason and AdBlock can’t removes div’s AFAIK. The solution I came up with was Greasemonkey

After installing the plugin go back to that article you were reading. Right click on the Greasemonkey icon on the right side of Firefox’s status bar and choose to add a new script. Fill out the Dialog that pop’s up (see screenshot), make sure to give an URL for the namespace, a fake one will do, and to set the include line to “http://www.infoworld.com/*”.

GreaseMonkey

Click on the Greasemokey dialog box and your editor should pop up. This is where you write the code for your script, which is just plain Javascript. So our goal is to get rid of the annoying toolbar which just happens to have the fixed ID of “floating_tools”, making our script REALLY simple. Remember to keep the comments that were originally in the file.

// ==UserScript==
// @name           KSTB
// @namespace      http://greasemonkey.circuitsofimagination.com/
// @description    Kill the Share it Tool Bar
// @include        http://www.infoworld.com/*
// ==/UserScript==

var toolbarElement = document.getElementById("floating_tools");
toolbarElement.parentNode.removeChild(toolbarElement);

Save the script and close the editor. Refresh the infoworld page and magically no more annoying toolbar. Even better you are now a 1337 c0d3r cuz you writes amazing greasemokey scripties. Congradulations!

For more in-depth info go to the Greasemokeys Hacks Wiki which is where I learned to do this from.