Hi friends,
Greasemonkey is basically a fire fox extension which allows users to install scripts that make on-the-fly changes to HTML web page content on the DOMContentLoaded event, which happens immediately after it is loaded in the browser.
Created by Aaron Boodman and Released on 2004-12-06.
Firefox Extension but also works for SeaMonkey, Opera, Chrome, Safari and IE.
Simply we can define Greasemonkey = JS+DOM(+CSS).
Din't get much??dont wory as the journey goes on you wil be cleared with all the terms...
Its ok man, but now a days almost all web pages are attractive, then what is the Need OF Greasemonkey??
You are right buddy but making changes in HTML page appearing in your browser as per your convenient is not the only purpose of greasemonkey..lets see its basic need
What is User Script??
Installing Greasemonkey...
Greasemonkey is basically a fire fox extension which allows users to install scripts that make on-the-fly changes to HTML web page content on the DOMContentLoaded event, which happens immediately after it is loaded in the browser.
Created by Aaron Boodman and Released on 2004-12-06.
Firefox Extension but also works for SeaMonkey, Opera, Chrome, Safari and IE.
Simply we can define Greasemonkey = JS+DOM(+CSS).
Din't get much??dont wory as the journey goes on you wil be cleared with all the terms...
Its ok man, but now a days almost all web pages are attractive, then what is the Need OF Greasemonkey??
You are right buddy but making changes in HTML page appearing in your browser as per your convenient is not the only purpose of greasemonkey..lets see its basic need
- Browsers and the Internet expose operating systems to environments that are malicious.
- To make the websites you visit more secure.
- Changing features of some websites according to user will.
- Customize the way a web page displays or behaves, by using small bits of JavaScript.
- Automatically retrieve data from other sites to make two sites more interconnected.
- Suppressing the advertisements on a page.
- Altering links that redirect so that they go directly to the desired target.
What is User Script??
- A user script is just a chunk of Java script code, that tells Greasemonkey where and when it should run.
- Greasemonkey scripts are persistent.
- A user script can do anything user can do in Javascript.
Installing Greasemonkey...
To obtain all the
applications discussed in the theoretical details we should install
it from http://diveintogreasemonkey.org/
to Mozilla Firefox.To start writing user scripts, you first need to
install the Greasemonkey browser extension, version 0.3 or later.
Procedure: Install the
Greasemonkey extension
1. Visit the Greasemonkey
home page <http://greasemonkey.mozdev.org/>.
2. Click the link titled
"Install Greasemonkey". Firefox will indicate (probably at
the top of your browser window) that it prevented the site from
installing software. Click Edit options... to bring up
the "Allowed Sites" dialog, then click Allow to
add the Greasemonkey site to your list of sites that are allowed to
install software.
3. Click OK to
close the "Allowed Sites" dialog.
4. Once again, click the
link titled "Install Greasemonkey".
5. Now an install dialog
should pop up to confirm that you really want to install. Wait a few
seconds for the install button to enable, then click Install
now.
6. Restart your browser.
Once you restart your
browser, select the Tools menu. You should see three
new menu items: Install User Script..., Manage
User Scripts..., and User Script Commands. Only
Manage User Scripts... will be enabled, but that's OK.
The others only become enabled under special circumstances.
By
default, installing Greasemonkey does not add any functionality to
your browser (other than those three menu items). All it does it
enable you to install additional items, called "user scripts",
which customize specific web pages.
Start writing your first user script "Hello World !"..
Fig 1.0 Entry for writing user script
As in fig. 1.0, one can
create his own script. Tool > Greasemonkey> New User
Script will open a new window asking about the basic
information about the script.
Fig 1.1 Window opened after clicking on New Script
Name:
The name of your script i.e. the user script.
Includes:
The URLs of the webpages which you expect the script to act over.
OK
for the first time will prompt you for selecting the Text Editor. You
can use Gedit (/usr/bin/gedit) or Notepad
(Installation_drive:\Windows\notepad.exe) for editing.
Fig 1.3 Hello World script!!!
The
name for the script is “Hello World” and it will act over
http://www.google.co.in/* webpage. OK will open the
text editor with some auto-generated comments.
Fig. 1.4 Window opened after clicking on OK.
As mentioned earlier, it’s all JavaScript. The name
of file containing the script must end in “user.js”
(hello_world.user.js).
alert(‘Hello,
World!’);
Fig.5 Printing ‘Hello world!’
You are, now, ready with your first user-script. Type
http://www.google.co.in in your Firefox browser to see the alert.
Fig 1.6
So i think now you are familiar with greasemonkey..Lets have some fun with greasemonkey
1) Redirecting Link of
facebook to google
Write a new script window.location=’http://www.google.com’
and write “http://www.facebook.com” in the include section. With this whenever
there’s a Facebook link you will always get redirected to Google.
2) Obtaining Download
button to Youtube
Here’s a script for downloading
YouTube’s videos: https://docs.google.com/document/pub?id=1Hlmy2IbEk44mI4IKpzJQ8HCJLzdgvW5binwP-_fLOI
. There is a install button click it and the script will be installed. There
is also a button of source code click on it to see script for this. After
installing script open youtube.com and we will find a Download button bellow
the video.
Fig 1.7 Download button to Yuo Tube
3) Facebook Security
To Redirect Gmail to an equivalent
https:// secure address we hav to simply write the following script.
window.location.href =
window.location.href.replace(/^http:/, 'https:');
This user script is very simple. Most
of the "work" is accomplished by the @include line: // @include http://facebook.com/*. This user script only runs if the @include matches.
Fig 1.8 Secure Facebook connection
Still you have any difficulty, you can watch following video showing the demo of how link redirect from google to facebook, How you can manage your script and to change the contents of HTML page..
So now I hope you enjoyed the journey of greasemonkey. For any query or suggestion you can post here..
Thank you !!!








No comments:
Post a Comment