Last active
June 8, 2017 12:08
-
-
Save eyecatchup/151d259ee151c16a0a1dd6a2afb5aaa1 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
var arr = document.querySelectorAll('iframe'); | |
for (i in arr) { | |
if (!!arr[i].src && arr[i].src.startsWith('https://openload')) { | |
//console.log(arr[i].src); | |
!arr[i].src || window.open(arr[i].src, '_blank'); | |
break; | |
} | |
} | |
document.getElementById('player').addEventListener("DOMNodeInserted", function(evt) { | |
var el = evt.target; | |
if (el.tagName && el.tagName === 'IFRAME' && el.src.startsWith('https://openload')) { | |
!el.src || window.open(el.src, '_top'); | |
} | |
}, 0); | |
document.addEventListener("DOMNodeInserted", function(evt) { | |
var el = evt.target; | |
if (el.tagName && el.tagName === 'IFRAME' && el.src.startsWith('https://openload')) { | |
console.log(el.src); | |
!el.src || window.open(el.src, '_blank'); | |
} | |
}, 0); |
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
(function(window) { | |
"use strict"; | |
var mutations = { | |
attrib: [], | |
childs: { | |
add: [], | |
del: [] | |
} | |
}; | |
// @return void | |
function onMutationsCallback(moRecords, moInstance) { | |
"use strict"; | |
moRecords.forEach(function(mutation) { | |
console.log('Mutation type: ' + mutation.type); | |
if ( mutation.type == 'childList' ) { | |
if (mutation.addedNodes.length >= 1) { | |
if (mutation.addedNodes[0].nodeName != '#text') { | |
console.log('Added ' + mutation.addedNodes[0].tagName + ' tag.'); | |
} | |
for (var i, i = 0; i < mutation.addedNodes.length; i++) { | |
mutations.childs.add.push(mutation.addedNodes[i]); | |
} | |
} | |
else if (mutation.removedNodes.length >= 1) { | |
console.log('Removed ' + mutation.removedNodes[0].tagName + ' tag.'); | |
for (var i, i = 0; i < mutation.removedNodes.length; i++) { | |
mutations.childs.del.push(mutation.removedNodes[i]); | |
} | |
} | |
} | |
else if (mutation.type == 'attributes') { | |
console.log('Modified ' + mutation.attributeName + ' attribute.'); | |
mutations.attrib.push(mutation); | |
} | |
}); | |
} | |
// Add a new registered observer of type MutationObserver (/w fallback support for legacy vendor-prefixed browser implementations) | |
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; | |
var mo = new MutationObserver(onMutationsCallback); | |
// The target node (or node list), whose DOM tree is to be observed | |
var $targetNodes = window.document.body; // Or, e.g., more specific: document.querySelector('some selector(s)'); | |
// The observer options (a MutationObserverInit dictionary) for this instance. | |
var observerOpts = { | |
attributes: true, // Set to true if mutations to target's *attributes* are to be observed. | |
characterData: true, // Set to true if mutations to target's data are to be observed. | |
childList: true, // Set to true if mutations to target's *children* are to be observed. | |
subtree: false // Set to true if mutations to target's, and also its descendants are to be observed. | |
}; | |
// Define a target node, or node list, for the observer instance to be bound to, set the instance options and (finally) start observing. | |
// @return void | |
mo.observe($targetNodes, observerOpts); | |
// Empty the observer-instance record-queue and return what was in there. | |
// @return array | |
//mo.takeRecords(); | |
// Stop observer instance from observing any mutations (until observe() method is used again). | |
// @return void | |
//mo.disconnect(); | |
//window["mo"] = mo; | |
})(window); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment