Greasemonkey template

A simple template for Greasemonkey scripts, ready to copy and paste :-)
(Name the file example.user.js so that Greasemonkey recognizes it)

// ==UserScript==
// @name            Greasemonkey Script Name
// @author          Your name
// @namespace       http://www.example.url/to/your-web-site/
// @description     Put a good description in here
// @license         Creative Commons Attribution License
// @version	        0.1
// @include         http://www.example.org/*
// @released        2006-04-17
// @updated         2006-04-19
// @compatible      Greasemonkey
// ==/UserScript==
 
/* 
 * This file is a Greasemonkey user script. To install it, you need 
 * the Firefox plugin "Greasemonkey" (URL: http://greasemonkey.mozdev.org/)
 * After you installed the extension, restart Firefox and revisit 
 * this script. Now you will see a new menu item "Install User Script"
 * in your tools menu.
 * 
 * To uninstall this script, go to your "Tools" menu and select 
 * "Manage User Scripts", then select this script from the list
 * and click uninstall :-)
 *
 * Creative Commons Attribution License (--> or Public Domain)
 * http://creativecommons.org/licenses/by/2.5/
*/
 
(function(){
 
    //object constructor
    function example(){
 
        // modify the stylesheet
        this.append_stylesheet('body,div { border: 1px solid red; }');
 
    };
 
    //create a stylesheet
    example.prototype.append_stylesheet = function(css){
 
        var styletag = document.createElement("style");
        styletag.setAttribute('type', 'text/css');
        styletag.setAttribute('media', 'screen');
        styletag.appendChild(document.createTextNode(css));
 
        document.getElementsByTagName('head')[0].appendChild(styletag);
 
    };
 
    //instantiate and run 
    var example = new example();
 
 
})();
 
// you can completely copy this template, including
// the install description, have fun! :-)
Snippet Details




Sorry folks, comments have been deactivated for now due to the large amount of spam.

Please try to post your questions or problems on a related programming board, a suitable mailing list, a programming chat-room,
or use a QA website like stackoverflow because I'm usually too busy to answer any mails related
to my code snippets. Therefore please just mail me if you found a serious bug... Thank you!


Older comments:

None.