repeat the scroll two times to ensure proper webpage load
This commit is contained in:
parent
a3749c71d2
commit
f4821010b0
1 changed files with 9 additions and 3 deletions
8
scripts/external/scraper.js
vendored
8
scripts/external/scraper.js
vendored
|
@ -10,11 +10,17 @@ export default class scraper {
|
||||||
function autoscroll() {
|
function autoscroll() {
|
||||||
let SCROLL = {"x": window.scrollX, "y": window.scrollY};
|
let SCROLL = {"x": window.scrollX, "y": window.scrollY};
|
||||||
|
|
||||||
[{"top": 0, "left": 0, "behavior": "smooth"}, {"top": document.body.scrollHeight, "left": document.body.scrollWidth, "behavior": "smooth"}, {"top": SCROLL[`y`], "left": SCROLL[`x`], "behavior": "smooth"}].forEach((POSITION) => {
|
// Repeat two times to ensure proper webpage load.
|
||||||
|
for (let TIMES = 1; TIMES <= 2; TIMES++) {
|
||||||
|
[{"top": 0, "left": 0, "behavior": "smooth"}, {"top": document.body.scrollHeight, "left": document.body.scrollWidth, "behavior": "smooth"}].forEach((POSITION) => {
|
||||||
window.scrollTo(POSITION);
|
window.scrollTo(POSITION);
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Scroll back to user's previous position.
|
||||||
|
window.scrollTo({"top": SCROLL[`y`], "left": SCROLL[`x`], "behavior": "smooth"});
|
||||||
|
};
|
||||||
|
|
||||||
autoscroll();
|
autoscroll();
|
||||||
|
|
||||||
if ((typeof scraper_fields).includes("object") && scraper_fields != null && scraper_fields) {
|
if ((typeof scraper_fields).includes("object") && scraper_fields != null && scraper_fields) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue