Skip to content

Instantly share code, notes, and snippets.

@pyxze
Last active December 25, 2015 00:19
Show Gist options
  • Save pyxze/6886411 to your computer and use it in GitHub Desktop.
Save pyxze/6886411 to your computer and use it in GitHub Desktop.
Mute Turntable for one song
// Based on http://eli.eliandlyndi.com/2011/06/28/turntable-fm-mute-until-next-track-starts/
// To use this make a bookmark then save this as the url and click it when needed.
javascript:
(function() {
function toggleMute() {
$(".volume-icon").click();
}
toggleMute();
console.log("muted!");
var $messagesDiv = $(".messages");
function onMessageReceived(event) {
if (event.target.tagName !== "DIV") {
return;
}
var $message = $("div:last span:eq(1)", this);
setTimeout(function() {
var message = $message.text();
if (message.indexOf(" started playing") !== 0) {
return;
}
console.log("volume up!");
$messagesDiv.unbind("DOMNodeInserted", onMessageReceived);
toggleMute();
}, 25);
}
$messagesDiv.unbind("DOMNodeInserted", onMessageReceived).bind("DOMNodeInserted", onMessageReceived);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment