Skip to content

Instantly share code, notes, and snippets.

@benlumley
Created October 11, 2010 20:47
Show Gist options
  • Save benlumley/621194 to your computer and use it in GitHub Desktop.
Save benlumley/621194 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name hotpotato
// @namespace hotpotato
// @description hotpotato
// @include http://hotpotato.heroku.com/*
// ==/UserScript==
// 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/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;
letsJQuery();
}
}
// All your GM code must be inside this function
function letsJQuery() {
document.timer = setInterval(function () { if ($('button').length) { $('button').click(); unsafeWindow.clearInterval(document.timer); return; } }, 100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment