mirror of
https://github.com/tubearchivist/browser-extension.git
synced 2024-11-05 03:30: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 => {
|
||||
if (list.some(i => i.type === 'childList' && i.addedNodes.length > 0)) {
|
||||
console.log("observer hit")
|
||||
ensureTALinks();
|
||||
throttle(ensureTALinks, 700);
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user