blob: 62362c1065ffb5b91b7a5512fe2be27ce77df9c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
function init_paging() {
const el = document.querySelector(".next_page") as HTMLAnchorElement
if (!el) return
document.body.onscroll = () => {
const end = document.body.clientHeight - document.body.parentElement!.scrollTop - document.body.parentElement!.clientHeight
if (end < 200) {
document.body.onscroll = () => { }
load_next(el)
}
}
}
async function load_next(el: HTMLAnchorElement) {
const res = await fetch(el.href + "&no_scaff")
if (!res.ok) throw "aaa"
const ext = await res.text()
el.remove()
document.getElementById("main")!.innerHTML += ext
init_paging()
}
globalThis.addEventListener("DOMContentLoaded", init_paging)
|