Last active
December 25, 2015 00:19
-
-
Save pyxze/6886411 to your computer and use it in GitHub Desktop.
Mute Turntable for one song
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
// 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