-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFanboxAutoOpenBlank.user.js
42 lines (36 loc) · 1.09 KB
/
FanboxAutoOpenBlank.user.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
// ==UserScript==
// @name FanboxAutoOpenBlank
// @namespace Yr
// @version 1.0
// @description Auto open link in new tab, worked with FanboxAutoDownload
// @author yanagiragi
// @match https://*.fanbox.cc/
// @icon https://www.google.com/s2/favicons?domain=fanbox.cc
// @grant none
// ==/UserScript==
let links = [];
let interval;
const scrollCheckTimeout = 3;
const checkInterval = scrollCheckTimeout + 30;
(function () {
'use strict';
interval = setInterval(Update, 1000 * checkInterval);
Update();
})();
function Cancel() { clearInterval(interval); }
function Update() {
window.scrollTo(0, document.body.scrollHeight);
// wait for ajax to work
setTimeout(() => {
CheckForLinks().forEach(x => {
if (!links.includes(x)) {
window.open(x, "_blank")
links.push(x)
}
})
links = [...new Set(links)]
}, 1000 * scrollCheckTimeout)
}
function CheckForLinks() {
return [...new Set([...document.querySelectorAll('.sc-11axwx2-0.bXrzaX a')].map(x => x.href))]
}