mirror of
https://github.com/tubearchivist/browser-extension.git
synced 2024-11-22 19:50:12 +00:00
throttle block for observer
This commit is contained in:
parent
30f80ca01a
commit
e87468900c
@ -355,10 +355,20 @@ function sendUrl(url, action, button) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
let throttleBlock;
|
||||||
|
const throttle = (callback, time) => {
|
||||||
|
if (throttleBlock) return;
|
||||||
|
throttleBlock = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
console.log("observer hit");
|
||||||
|
callback();
|
||||||
|
throttleBlock = false;
|
||||||
|
}, time);
|
||||||
|
};
|
||||||
|
|
||||||
let observer = new MutationObserver(list => {
|
let observer = new MutationObserver(list => {
|
||||||
if (list.some(i => i.type === 'childList' && i.addedNodes.length > 0)) {
|
if (list.some(i => i.type === 'childList' && i.addedNodes.length > 0)) {
|
||||||
console.log("observer hit")
|
throttle(ensureTALinks, 700);
|
||||||
ensureTALinks();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user