Last active
August 29, 2015 14:06
-
-
Save keratagpro/4337aacb95aa04fea953 to your computer and use it in GitHub Desktop.
Autowoot and stuff for plug.dj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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