-
-
Save mattsgarrison/1166339 to your computer and use it in GitHub Desktop.
Turntable.fm DJ Script
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
javascript:(function(g,d,f){if(f)d.info("Session found:",f);else return d.warn("No session found!");var h={check:10,wait:500},b=g.autodj={api:g[f],available:function(a){return b.api.taken_dj_map[a]<0},spot:function(){return b.api.become_dj.data("spot")},become:function(a){b.api.callback("become_dj",a)},waiter:function(a){return function(){return b.available(a)?(b.become(a),a):(d.info("Waiting..."),-1)}},seated:function(a){return b.api.djs[a]&&b.api.djs[a][0]===b.api.myuserid},wait:function(a,c){var e=c!==void 0, | |
a=a||h.check,c=c||b.spot();b.seated(c)?d.warn("Spot",c,"taken!"):(e&&d.error("Spot",c,"missed. Restarting..."),d.info("Polling @",a,"ms"),b.check(a,b.waiter(c)))},check:function(a,c){setTimeout(function(){var e=c.call(b);e>0?(d.warn("Spot",e,"open..."),setTimeout(function(){b.wait(a,e)},h.wait)):b.check(a,c)},a)}}})(window,console,function(g,d,f,h,b,a,c,e,i,j,k){try{return g(d)[f](h)[b][a][c][e]()[i](j)[k]}catch(l){return null}}(jQuery,".invite_dj","data","events","click",0,"handler","toString","match", | |
/\{\s*(.+)\./,1));autodj.wait(); |
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
/*global window, console, jQuery */ | |
(function(global, out, session){ | |
if (!session) { | |
return out.warn("No session found!"); | |
} else { | |
out.info("Session found:", session); | |
} | |
var config = { check: 10, wait: 500 }, | |
dj = global.autodj = { | |
api: global[session], | |
available: function(spot) { | |
return dj.api.taken_dj_map[spot] < 0; | |
}, | |
spot: function() { | |
return dj.api.become_dj.data("spot"); | |
}, | |
become: function(spot) { | |
dj.api.callback("become_dj", spot); | |
}, | |
waiter: function(spot) { | |
return function() { | |
if (dj.available(spot)) { | |
dj.become(spot); | |
return spot; | |
} else { | |
out.info("Waiting..."); | |
return -1; | |
} | |
}; | |
}, | |
seated: function(spot) { | |
return dj.api.djs[spot] && dj.api.djs[spot][0] === dj.api.myuserid; | |
}, | |
wait: function(interval, spot) { | |
var reload = spot !== undefined; | |
interval = interval || config.check; | |
spot = spot || dj.spot(); | |
if (dj.seated(spot)) { | |
out.warn("Spot", spot, "taken!"); | |
} else { | |
if (reload) { | |
out.error("Spot", spot, "missed. Restarting..."); | |
} | |
out.info("Polling @", interval, "ms"); | |
dj.check(interval, dj.waiter(spot)); | |
} | |
}, | |
check: function(interval, waiter) { | |
setTimeout(function(){ | |
var spot = waiter.call(dj); | |
if (spot > 0) { | |
out.warn("Spot", spot, "open..."); | |
setTimeout(function(){ | |
dj.wait(interval, spot); | |
}, config.wait); | |
} else { | |
dj.check(interval, waiter); | |
} | |
}, interval); | |
} | |
}; | |
})(window, console, (function($,_t,u,r,n,t,a,b,l,e,fm){ | |
try { return $(_t)[u](r)[n][t][a][b]()[l](e)[fm]; } | |
catch(fail) { return null; } | |
})(jQuery, ".invite_dj", "data", "events", "click", 0, | |
"handler", "toString", "match", /\{\s*(.+)\./, 1)); |
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
(function(g,d,f){if(f)d.info("Session found:",f);else return d.warn("No session found!");var h={check:10,wait:500},b=g.autodj={api:g[f],available:function(a){return b.api.taken_dj_map[a]<0},spot:function(){return b.api.become_dj.data("spot")},become:function(a){b.api.callback("become_dj",a)},waiter:function(a){return function(){return b.available(a)?(b.become(a),a):(d.info("Waiting..."),-1)}},seated:function(a){return b.api.djs[a]&&b.api.djs[a][0]===b.api.myuserid},wait:function(a,c){var e=c!==void 0, | |
a=a||h.check,c=c||b.spot();b.seated(c)?d.warn("Spot",c,"taken!"):(e&&d.error("Spot",c,"missed. Restarting..."),d.info("Polling @",a,"ms"),b.check(a,b.waiter(c)))},check:function(a,c){setTimeout(function(){var e=c.call(b);e>0?(d.warn("Spot",e,"open..."),setTimeout(function(){b.wait(a,e)},h.wait)):b.check(a,c)},a)}}})(window,console,function(g,d,f,h,b,a,c,e,i,j,k){try{return g(d)[f](h)[b][a][c][e]()[i](j)[k]}catch(l){return null}}(jQuery,".invite_dj","data","events","click",0,"handler","toString","match", | |
/\{\s*(.+)\./,1)); |
OHHHH I seeeeeeeeeeeeee crafty
Yeah...you gotta make it a bookmarklet, I haven't tried it in a couple days though. This gist was just a fork, I didn't write it.
how do install/save the bookmarklet? and what do u do with the .min.js file
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this still work? My brief experiment seems to suggest no...