Skip to content

Instantly share code, notes, and snippets.

@dbknickerbocker
Last active December 15, 2015 17:59
Show Gist options
  • Save dbknickerbocker/5300881 to your computer and use it in GitHub Desktop.
Save dbknickerbocker/5300881 to your computer and use it in GitHub Desktop.
// ==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