var woot = document.querySelector('#woot');
var song = document.querySelector('#now-playing-media');
var date = function () {
return new Date().toLocaleString().replace(',', '');
};
var observer = new MutationObserver(function(mutation) {
var wootable = woot.querySelector('.icon-woot');
if (wootable) {
console.log('autowoot @ %s: %s', date(), song.innerText);
var click = document.createEvent('HTMLEvents');
click.initEvent('click', true, true);
woot.dispatchEvent(click);
}
});
observer.observe(woot, { attributes: true });
// var SIX_HOURS_IN_MILLISECONDS = 216e5;
// var turnOffAutowoot = setTimeout(function() {
// console.log('disabling autowoot @ %s', date());
// observer.disconnect();
// }, SIX_HOURS_IN_MILLISECONDS);