Greasemonkey + jQuery = 1337
July 30th, 2010
No comments
Got some inspiration from this site for the base script: click
I wanted a site to always show the answer ‘Ja’ (Dutch for yes). Which was normally only shown at a specific time. (The question was if you could start drinking beer. ;))
Here is the full script:
// ==UserScript== // @name ishetalbiertijd.user.js // @namespace http://famvdploeg.com/greasemonkey // @include http://www.ishetalbiertijd.nl/* // ==/UserScript== var $; // Add jQuery (function(){ if (typeof unsafeWindow.jQuery == 'undefined') { var GM_Head = document.getElementsByTagName('head')[0] || document.documentElement, GM_JQ = document.createElement('script'); GM_JQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'; GM_JQ.type = 'text/javascript'; GM_JQ.async = true; GM_Head.insertBefore(GM_JQ, GM_Head.firstChild); } GM_wait(); })(); // Check if jQuery's loaded function GM_wait() { if (typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait, 100); } else { $ = unsafeWindow.jQuery.noConflict(true); letsJQuery(); } } // All your GM code must be inside this function function letsJQuery() { //@require does not work for us... $('span#answer').text('Jaaa!'); $('#datum').replaceWith('<span style="font-size: 200%; font-weight:bold; color:white">Het kan nu!</span>'); } |