This commit is contained in:
2021-11-01 18:38:58 -05:00
commit 0d2d278260
19 changed files with 875 additions and 0 deletions

26
runner/js/scroll.js Normal file
View File

@@ -0,0 +1,26 @@
async (limit,timeout) => {
const getScrollHeight = (element) => {
if (!element) return 0
const { scrollHeight, offsetHeight, clientHeight } = element
return Math.max(scrollHeight, offsetHeight, clientHeight)
}
const position = await new Promise((resolve) => {
let count = 0
let limit_counter = 0
const intervalId = setInterval(() => {
const { body } = document
const availableScrollHeight = getScrollHeight(body)
window.scrollBy(0, 250)
count += 250
limit_counter += 1
if (count >= availableScrollHeight || limit_counter > limit) {
clearInterval(intervalId)
resolve(count)
}
}, timeout)
})
return position
}