70 likes | 173 Views
Introduction To Greasemonkey. What is Greasemonkey?. A Firefox extension which allows a user to install scripts which will alter a web page on-the-fly. Useful for adding new functionality, fixing bugs, removing unwanted content, etc. User Scripts.
E N D
What is Greasemonkey? • A Firefox extension which allows a user to install scripts which will alter a web page on-the-fly. • Useful for adding new functionality, fixing bugs, removing unwanted content, etc.
User Scripts • Greasemonkey on its own doesn’t do anything. A user script must be installed in order to alter page content. • A user script must end in the “.user.js” file extension. • A user script can be installed via the Tools->New User Script menu item or by browsing to the script in Firefox.
User Script Metadata • Each script has a metadata section to tell Greasemonkey about itself. // ==UserScript== // @name TestScript // @namespace tag:hci.ucsd.edu,2001-06-05:ex // @description A Test script // @include http://hci.ucsd.edu/* // ==/UserScript==
GM API • Greasemonkey also supports some additional API in addition to JavaScript • GM_log – log messages to JavaScript Console • GM_getValue – get script specific config value • GM_setValue – set script specific config value • GM_registerMenuCommand – add a menu item to the User Script Commands submenu • GM_xmlhttpRequest – make an arbitrary HTTP request
Lets Install Some Scripts • Hello World // ==UserScript== // @name TestScript // @namespace tag:hci.ucsd.edu,2001-06-05:ex // @description A Test script // @include http://hci.ucsd.edu/* // ==/UserScript== alert(“Hello World”);
Useful Links • http://greasemonkey.mozdev.org • http://diveintogreasemonkey.org • http://dunck.us/collab • http://greaseblog.blogspot.com • http://www.oreilly.com/catalog/greasemonkeyhks