Skip to content

Instantly share code, notes, and snippets.

@elithompson
Created June 29, 2011 02:22
Show Gist options
  • Save elithompson/1052827 to your computer and use it in GitHub Desktop.
Save elithompson/1052827 to your computer and use it in GitHub Desktop.
Mute until next track starts
(function(){
function toggleMute() {
$(".mute_btn:first").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);
})();
@pyxze
Copy link

pyxze commented Oct 8, 2013

$(".mute_btn:first").click(); doesn't work anymore.

Try $(".volume-icon").click();.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment