Last active
December 15, 2015 17:59
-
-
Save dbknickerbocker/5300881 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Yes, Pandora, I'm Still Listening | |
// @namespace http://dbknickerbocker.blogspot.com | |
// @description Automatically click "I'm still listening" | |
// @match http://www.pandora.com/* | |
// @match https://www.pandora.com/* | |
// @updateURL https://gist.github.com/dbknickerbocker/5300881/raw/pandora_user_script.js | |
// @version 0.2 | |
// ==/UserScript== | |
function checkMutationForStillListening(mutation) { | |
if ((mutation === null) || (mutation.addedNodes === null)) { | |
return false; | |
} | |
for (var index = 0; index < mutation.addedNodes.length; ++index) { | |
var addedNode = mutation.addedNodes[index]; | |
if (addedNode === null) { | |
continue; | |
} | |
var stillListeningNode = addedNode.querySelector('a.still_listening'); | |
if (stillListeningNode !== null) { | |
stillListeningNode.click(); | |
return true; | |
} | |
} | |
return false; | |
} | |
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; | |
if (typeof MutationObserver !== 'undefined') { | |
var mutationObserver = new MutationObserver(function (mutations) { | |
mutations.some(checkMutationForStillListening); | |
}); | |
mutationObserver.observe(window.document, { childList: true, subtree: true }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment