2020-07-29 10:03:25 +02:00
|
|
|
let __scripts = [];
|
|
|
|
|
2020-07-29 10:35:57 +02:00
|
|
|
function registerScript(func) {
|
2020-07-29 10:03:25 +02:00
|
|
|
__scripts.push(func);
|
|
|
|
}
|
|
|
|
|
2020-07-29 11:14:38 +02:00
|
|
|
function runScripts(node) {
|
|
|
|
__scripts.forEach(script => script(node));
|
|
|
|
}
|
|
|
|
|
2020-07-29 10:35:57 +02:00
|
|
|
let observer = new MutationObserver(mutations => {
|
|
|
|
mutations.forEach(mutation => {
|
|
|
|
for (let i = 0; i < mutation.addedNodes.length; i++) {
|
2020-07-29 11:14:38 +02:00
|
|
|
runScripts(mutation.addedNodes[i]);
|
2020-04-25 22:20:26 +02:00
|
|
|
}
|
2020-07-29 10:35:57 +02:00
|
|
|
});
|
|
|
|
});
|
2020-07-29 10:03:25 +02:00
|
|
|
|
2020-07-29 10:35:57 +02:00
|
|
|
observer.observe(document.documentElement || document.body, {
|
|
|
|
childList: true,
|
2020-07-29 11:14:38 +02:00
|
|
|
subtree: true,
|
|
|
|
attributes: true
|
2020-07-29 10:35:57 +02:00
|
|
|
});
|