-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
skip_gamekee_popup.user.js
60 lines (52 loc) · 1.58 KB
/
skip_gamekee_popup.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// ==UserScript==
// @name skip gamekee popup
// @namespace https://github.com/x94fujo6rpg/SomeTampermonkeyScripts
// @updateURL https://github.com/x94fujo6rpg/SomeTampermonkeyScripts/raw/master/skip_gamekee_popup.user.js
// @version 0.2
// @description 自動關閉gamekee註冊訊息
// @author x94fujo6
// @include https://*.gamekee.com/*
// ==/UserScript==
(async function () {
function wait_tab() {
return new Promise(resolve => {
if (document.visibilityState === "visible") return resolve();
console.log("tab in background, script paused");
document.addEventListener("visibilitychange", () => {
if (document.visibilityState === "visible") { console.log("script unpaused"); return resolve(); }
});
});
}
function waitHTML(css_selector, run) {
let id = setInterval(() => {
if (document.querySelectorAll(css_selector).length) {
clearInterval(id);
run();
console.log(`found [${css_selector}]`);
} else {
console.log(`[${css_selector}] not found`);
}
}, 100);
}
function main() {
let css_selector = ".el-popup-parent--hidden";
removePopup();
waitHTML(css_selector, () => resumeBody(css_selector.replace(".", "")));
}
function removePopup() {
let css_selector = [
"body > .el-dialog__wrapper",
".v-modal"
].join(",");
document.querySelectorAll(css_selector)
.forEach(ele => {
ele.remove();
});
}
function resumeBody(class_name = "") {
document.body.style.overflow = "unset";
document.body.classList.remove(class_name);
}
await wait_tab();
waitHTML("body > .el-dialog__wrapper", main);
})();