Skip to content

Instantly share code, notes, and snippets.

@raldred
Last active September 1, 2015 11:09
Show Gist options
  • Save raldred/fc37faa3abb5ef96781b to your computer and use it in GitHub Desktop.
Save raldred/fc37faa3abb5ef96781b to your computer and use it in GitHub Desktop.
Digitally Imported Responsive Fix
// ==UserScript==
// @name Digitally Imported Unresponsive Fix
// @namespace http://robaldred.co.uk/
// @version 0.1
// @description Watches for the annoying unresponsive popup that's presented and resumes playback.
// @match http://www.di.fm/*
// @copyright 2015+, Rob Aldred
// ==/UserScript==
;(function(window) {
'use strict';
var listeners = [],
document = window.document,
MutationObserver = window.MutationObserver || window.WebKitMutationObserver,
observer;
function watch(selector, callback){
listeners.push({
selector: selector,
callback: callback
});
if(!observer){
// Watch for changes in the document
observer = new MutationObserver(check);
observer.observe(doc.documentElement, {
childList: true,
subtree: true
});
}
// Check if the element is currently in the DOM
check();
}
function checkVisibility(){
// Check the DOM for elements matching a stored selector
for(var i = 0, len = listeners.length, listener, elements; i < len; i++){
listener = listeners[i];
// Query for elements matching the specified selector
elements = doc.querySelectorAll(listener.selector);
for(var j = 0, jLen = elements.length, element; j < jLen; j++){
element = elements[j];
// Make sure the callback isn't invoked with the
// same element more than once
if(!element.ready){
element.ready = true;
// Invoke the callback with the element
listener.fn.call(element, element);
}
}
}
}
watch('#panel-unresponsive',function(element) {
});
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment