-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathNsDilemmaAutoClose.user.js
51 lines (46 loc) · 1.57 KB
/
NsDilemmaAutoClose.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
// ==UserScript==
// @name NsDilemmaAutoClose
// @version 0.5.1
// @namespace dithpri.RCES
// @description Auto-close resolved dilemma windows or offer to open a pack if it was generated
// @author dithpri
// @downloadURL https://github.com/dithpri/RCES/raw/master/userscripts/issue_answering/NsDilemmaAutoClose.user.js
// @noframes
// @match https://www.nationstates.net/*page=enact_dilemma*
// @grant window.close
// @run-at document-end
// ==/UserScript==
/*
* Copyright (c) 2019-2020 dithpri (Racoda) <[email protected]>
* This file is part of RCES: https://github.com/dithpri/RCES and licensed under
* the MIT license. See LICENSE.md or
* https://github.com/dithpri/RCES/blob/master/LICENSE.md for more details.
*/
// Credits to 9003 for also discovering the pack-opening shortcut and reminding
// me to push an update
function addStyle(style) {
"use strict";
var node = document.createElement("style");
node.innerHTML = style;
document.getElementsByTagName("head")[0].appendChild(node);
}
(function () {
"use strict";
const pack_open_btn = document.querySelector(".button.lootboxbutton");
if (pack_open_btn) {
addStyle("div, h5, p, #banner { display: none; } #main, #content, form p { display: initial;}");
pack_open_btn.scrollIntoView();
document.addEventListener("keyup", (ev) => {
if (ev.key != "Enter" || ev.repeat) {
ev.preventDefault();
return;
}
if (pack_open_btn.style.display != "none") {
pack_open_btn.style.display = "none";
pack_open_btn.click();
}
});
} else {
window.close();
}
})();