From 85ebecab4d2d09c2913d7ec55e6e15a25903a3c3 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:16:46 +0800 Subject: [PATCH] test: remove autoscroll --- src/scripts/platform/scraper.js | 36 +++++++++++++++------------------ 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/scripts/platform/scraper.js b/src/scripts/platform/scraper.js index c67939f..6ff814c 100644 --- a/src/scripts/platform/scraper.js +++ b/src/scripts/platform/scraper.js @@ -47,7 +47,7 @@ export default class scraper { }; // Check every 1 second to check until autosccroll is done. - function wait(OPTIONS) { + /*function wait(OPTIONS) { return new Promise((resolve, reject) => { // Check if autoscroll is done. if (!((typeof window).includes(`undef`))) { @@ -61,23 +61,21 @@ export default class scraper { reject(); } }); + }*/ + + this.getTexts(this.fields, this.#options); + this.getImages(this.fields, this.#options); + + if (this.#options.background) { + // Event listener when elements are added or removed. + const OBSERVER = new MutationObserver((mutations) => { + this.getTexts(this.fields, this.#options); + this.getImages(this.fields, this.#options); + }); + + // Observe the document. + OBSERVER.observe(document.body, {"childList": true, "subtree": true}); } - - wait(this.#options).then(() => { - this.getTexts(this.fields, this.#options); - this.getImages(this.fields, this.#options); - - if (this.#options.background) { - // Event listener when elements are added or removed. - const OBSERVER = new MutationObserver((mutations) => { - this.getTexts(this.fields, this.#options); - this.getImages(this.fields, this.#options); - }); - - // Observe the document. - OBSERVER.observe(document.body, {"childList": true, "subtree": true}); - } - }); } } @@ -125,9 +123,7 @@ export default class scraper { } else if ((typeof VALUE).includes(`obj`) && VALUE && !Array.isArray(VALUE)) { DATA[NAME] = read(VALUE); } else if (document.querySelector(VALUE)) { - (document.querySelector(VALUE)) - ? DATA[NAME] = document.querySelector(VALUE).textContent.trim() - : false; + DATA[NAME] = document.querySelector(VALUE).textContent.trim() }; }; });