-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4chan-auto-update-watcher.user.js
31 lines (26 loc) · 1.05 KB
/
4chan-auto-update-watcher.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
// ==UserScript==
// @name 4chan-auto-update-watcher
// @namespace github.com/diegostafa/userscripts
// @match https://boards.4chan.org/*/*
// @match https://boards.4channel.org/*/*
// @version 2
// @author Diego <[email protected]> (github.com/diegostafa)
// @description automatically update the thread watcher and the current thread every 5 seconds
// @run-at document-end
// ==/UserScript==
const autoUpdateWatcher = () => {
let refreshIcon = document.querySelector("#twPrune");
let clickEvent = document.createEvent("MouseEvents");
clickEvent.initEvent("mouseup", true, true);
refreshIcon.dispatchEvent(clickEvent);
setInterval(() => {
refreshIcon.dispatchEvent(clickEvent);
}, 5000);
};
const onThreadWatcherReady = () => {
if (!document.getElementById("threadWatcher")) return;
docObserver.disconnect();
autoUpdateWatcher();
};
const docObserver = new MutationObserver(onThreadWatcherReady);
docObserver.observe(document, { attributes: false, childList: true, subtree: true });