-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharcade-history.js
62 lines (54 loc) · 1.96 KB
/
arcade-history.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function lameify() {
if (!document.querySelectorAll('table').length) { return }
if (!document.getElementById('lame-progress-modal')) { addModal() }
main();
}
function addModal() {
let progressModal = Object.assign(document.createElement('dialog'), {
id: 'lame-progress-modal',
open: '',
style: 'padding: 2em; border: 0; box-shadow: #000 0px 0px 1em; border-radius: 5px;',
innerHTML: `
<p>Loading more entries...</p>
<progress id="tables-loading-progress" max="100" value="0" style="width: 100%"></progress>`,
});
document.body.append(progressModal);
let styleSheet = Object.assign(document.createElement('style'), {
textContent: `
dialog::backdrop {
background: #000;
opacity: 0.5;
transition: opacity .15s linear;
}
`,
});
document.head.appendChild(styleSheet);
}
function main() {
let initialEntryCount = document.querySelectorAll('table').length;
let remoteTotal = parseInt(document.querySelector('.fs-12.font-bold').textContent.replace(',', ''));
let progressModal = document.getElementById('lame-progress-modal');
if (initialEntryCount < remoteTotal) {
progressModal.showModal()
} else {
alert('No more results.');
return
}
let LIMIT_PER_CLICK = initialEntryCount + 400; /* Just so it doesn't take too long */
let stopPoint = (remoteTotal < LIMIT_PER_CLICK) ? remoteTotal : LIMIT_PER_CLICK;
let progressBar= document.getElementById('tables-loading-progress');
let clickerInterval = setInterval(()=>{
let loadedEntryCount = document.querySelectorAll('table').length;
console.log(`Loaded entries: ${loadedEntryCount}`);
progressBar.value = (loadedEntryCount - initialEntryCount) / (stopPoint - initialEntryCount) * 100;
if (loadedEntryCount < stopPoint) {
document.querySelector('.btn-primary.full-width').click()
}
else {
progressBar.value = 0;
progressModal.close();
clearInterval(clickerInterval);
}
}, 500);
}
/* lameify() */