Skip to content

Instantly share code, notes, and snippets.

@keratagpro
Last active August 29, 2015 14:06
Show Gist options
  • Save keratagpro/4337aacb95aa04fea953 to your computer and use it in GitHub Desktop.
Save keratagpro/4337aacb95aa04fea953 to your computer and use it in GitHub Desktop.
Autowoot and stuff for plug.dj
// ==UserScript==
// @name Autowoot
// @namespace http://sample.com
// @version 0.1
// @description Autowoot
// @match https://plug.dj/*
// @run-at document-end
// @grant unsafeWindow
// ==/UserScript==
function main() {
var $ = window.$;
var API = window.API;
$("#woot").click();
API.on(API.ADVANCE, function() {
$("#woot").click();
});
window.onbeforeunload = function(){
return "Do you want to leave?";
};
}
function appendMain() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.appendChild(document.createTextNode('('+ main +')();'));
(document.body || document.head || document.documentElement).appendChild(s);
}
function checkReady() {
if (unsafeWindow.API && unsafeWindow.API.enabled) {
setTimeout(appendMain, 2000);
}
else {
console.debug('API not loaded yet, retrying in 1s.');
setTimeout(checkReady, 1000);
}
};
checkReady();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment