mirror of
https://github.com/tcsenpai/Zundler.git
synced 2025-06-06 11:35:40 +00:00
Fix observation of mutated elements
Needs to be installed after DOM loaded.
This commit is contained in:
parent
a479b350e9
commit
2399acaabd
@ -57,24 +57,6 @@ var onScrollToAnchor = function(argument) {
|
||||
}
|
||||
|
||||
|
||||
const observer = new MutationObserver((mutationList) => {
|
||||
// console.log("Fix mutated elements...", mutationList);
|
||||
mutationList.forEach((mutation) => {
|
||||
if (mutation.type == 'childList') {
|
||||
Array.from(mutation.target.querySelectorAll("a")).forEach( a => {
|
||||
fixLink(a);
|
||||
});
|
||||
Array.from(mutation.target.querySelectorAll("img")).forEach( img => {
|
||||
embedImg(img);
|
||||
});
|
||||
Array.from(mutation.target.querySelectorAll("form")).forEach( form => {
|
||||
fixForm(form);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var monkeyPatch = function() {
|
||||
if (typeof jQuery === 'undefined') {return;} // Only for jQuery at the moment
|
||||
/**
|
||||
|
@ -108,3 +108,25 @@ window.fetch = async (...args) => {
|
||||
}
|
||||
return response;
|
||||
};
|
||||
|
||||
|
||||
const observer = new MutationObserver((mutationList) => {
|
||||
console.log("Fix mutated elements...", mutationList);
|
||||
mutationList.forEach((mutation) => {
|
||||
if (mutation.type == 'childList') {
|
||||
Array.from(mutation.target.querySelectorAll("a")).forEach( a => {
|
||||
fixLink(a);
|
||||
});
|
||||
Array.from(mutation.target.querySelectorAll("img")).forEach( img => {
|
||||
embedImg(img);
|
||||
});
|
||||
Array.from(mutation.target.querySelectorAll("form")).forEach( form => {
|
||||
fixForm(form);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function (event) {
|
||||
observer.observe(window.document.body, {subtree: true, childList: true});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user