Intelligent and creative users of the internet use firefox. There are numerous advantages, while using firefox. This might sound a rude statement, “I have never had any respect for a person involved in design or just software, using internet explorer”. if you have not switched till now, make it happen today. get firefox.
I love to code, and it is double joy, when writing grease monkey scripts. I definitely drew more enjoyment and satisfaction when writing a greasemonkey, than when writing a shell script or a pl/sql procedure. A grease monkey script is a more visualized and more enjoyable.
In technical terms, a greasemonkey is a addon in firefox, which lets you run scripts of code, after a page has loaded. Of course, you can select, what scripts of yours, run in what pages. For instance, you may want to run a script, every time, you are in the wikipedia domain. Wild cards are also supported.
This was one of my first scripts. This is more of a example of a greasemonkey, for it does no real work. but if you just want to show off, this script is one for you.
What does it do?
It replaces the google logo on the google homepage, with your own name.
Ok, lets get started.
Step 1. If you don’t have firefox, get it.
Step 2. Download greasemonkey. You can get all addons at mozilla
Step3. Restart Firefox. There is a addon for this too.
Step 4. Create your own logo, just like google. I know everybody loves their name, or at least their nick names. Create your own pic here, and upload it somewhere, say flickr or on your own server.![]()
Step 5. Time to write some code.
Tools-> Greasemonkey -> New User Script
Give a name to your script, it can be any valid name.
forget the name space, it is not for amateurs. Just some text.
Description - i hate this.. just dump in some text.
Includes - This is where, you have to tell firefox, on which sites, you want to run this script. Our target for this script will be google search. So you may say *.google.*, meaning, it would run this script on all websites under the google domain. Say OK to complete the form. You may be prompted to select a text editor. Choose notepad or some other editor. I like editplus.
Too late already, lets code.
//alert(”control reaches this script”);
var back = document.getElementsByTagName(’img’);
var bg = back[0];
if (bg!=null)
{ //alert(”control reaches here”);
bg.setAttribute(’src’,”http://codeinsane.com/pics/codeinsane.gif”); }
//alert(”control reaches out”);
Copy all of the text in italics above and save it. You have to replace the url in the code, with your own url. (from flickr or own server). Take a minute to understand the code, of all languages i know, javascript is cool and easy to learn. if something does not make sense to you, ask me.
All done, ensure the monkey laughs in your status bar, else click on it. (It must toggle to laugh now)
Go to google.com to see your code work.
If you don’t see your url on the page, try removing those comments to track the flow of your code. Still got a problem, drop a comment and let me know.
My first post, involving code (though just a couple of lines). Users please let me know, if you have more ideas to implement. You may like to see a ocean of scripts online. Just google for greasemonkey scripts.




1 user commented in " play with greasemonkey "
Follow-up comment rss or Leave a Trackback[…] I had written about how to get started with a greasemonkey. It was a simple small script on how to change the google logo with your font. It showed you how to install greasemonkey and write your first script. This is possibly a second […]
Leave A Reply - Opinionate..