|
@@ -30,7 +30,17 @@ this.lazyLoader = this.lazyLoader || (() => {
|
|
|
|
|
|
|
|
function process() {
|
|
function process() {
|
|
|
return new Promise(resolve => {
|
|
return new Promise(resolve => {
|
|
|
- let timeoutId, maxTimeoutId, idleTimeoutId, srcAttributeChanged;
|
|
|
|
|
|
|
+ let timeoutId, srcAttributeChanged;
|
|
|
|
|
+ const idleTimeoutId = timeout.set(() => {
|
|
|
|
|
+ if (!srcAttributeChanged) {
|
|
|
|
|
+ timeout.clear(timeoutId);
|
|
|
|
|
+ lazyLoadEnd(maxTimeoutId, idleTimeoutId, observer, resolve);
|
|
|
|
|
+ }
|
|
|
|
|
+ }, IDLE_LAZY_LOADING_TIMEOUT);
|
|
|
|
|
+ const maxTimeoutId = timeout.set(() => {
|
|
|
|
|
+ timeout.clear(timeoutId);
|
|
|
|
|
+ lazyLoadEnd(maxTimeoutId, idleTimeoutId, observer, resolve);
|
|
|
|
|
+ }, MAX_LAZY_LOADING_TIMEOUT);
|
|
|
const observer = new MutationObserver(mutations => {
|
|
const observer = new MutationObserver(mutations => {
|
|
|
if (mutations.find(mutation => mutation.type == "attributes")) {
|
|
if (mutations.find(mutation => mutation.type == "attributes")) {
|
|
|
srcAttributeChanged = true;
|
|
srcAttributeChanged = true;
|
|
@@ -42,16 +52,6 @@ this.lazyLoader = this.lazyLoader || (() => {
|
|
|
scriptBeforeElement.src = browser.runtime.getURL("lib/lazy/web-lazy-loader-before.js");
|
|
scriptBeforeElement.src = browser.runtime.getURL("lib/lazy/web-lazy-loader-before.js");
|
|
|
document.body.appendChild(scriptBeforeElement);
|
|
document.body.appendChild(scriptBeforeElement);
|
|
|
scriptBeforeElement.onload = () => scriptBeforeElement.remove();
|
|
scriptBeforeElement.onload = () => scriptBeforeElement.remove();
|
|
|
- idleTimeoutId = timeout.set(() => {
|
|
|
|
|
- if (!srcAttributeChanged) {
|
|
|
|
|
- timeout.clear(timeoutId);
|
|
|
|
|
- lazyLoadEnd(maxTimeoutId, idleTimeoutId, observer, resolve);
|
|
|
|
|
- }
|
|
|
|
|
- }, IDLE_LAZY_LOADING_TIMEOUT);
|
|
|
|
|
- maxTimeoutId = timeout.set(() => {
|
|
|
|
|
- timeout.clear(timeoutId);
|
|
|
|
|
- lazyLoadEnd(maxTimeoutId, idleTimeoutId, observer, resolve);
|
|
|
|
|
- }, MAX_LAZY_LOADING_TIMEOUT);
|
|
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|