-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGardener Highlighter.user.js
123 lines (111 loc) · 9.6 KB
/
Gardener Highlighter.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// ==UserScript==
// @name Gardener Highlighter
// @version 0.7.3
// @namespace dithpri.RCES
// @description Adds The Card Gardening Society's icon besides members during auctions
// @author dithpri
// @downloadURL https://github.com/dithpri/RCES/raw/master/userscripts/auction/Gardener%20Highlighter.user.js
// @noframes
// @match https://www.nationstates.net/*page=deck*/*card=*
// @match https://www.nationstates.net/*card=*/*page=deck*
// @grant GM.xmlHttpRequest
// @grant GM.setValue
// @grant GM.getValue
// @connect docs.google.com
// @connect googleusercontent.com
// ==/UserScript==
/*
* Copyright (c) 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.
*/
/* Permissions:
*
* GM.xmlHttpRequest, `connect docs.google.com`, `connect googleusercontent.com`:
* to automatically fetch and update members' nations.
*
* GM.setValue, GM.getValue:
* to save and load members' nations locally.
*/
function GM_addStyle(style) {
"use strict";
var node = document.createElement("style");
node.innerHTML = style;
document.getElementsByTagName("head")[0].appendChild(node);
}
const icon_base64 =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAA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Tp0aW1lc3RhbXAAMjAyNC0wNC0wOFQyMjoyOTowOSswMDowMFzdWAIAAAAZdEVYdFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAAAAElFTkSuQmCC";
(async function () {
"use strict";
const update_auctiontable = async function () {
const members_array = (await GM.getValue("cardgardens", "")).split("\n");
document.querySelectorAll("#cardauctiontable > tbody > tr > td > p > a.nlink").forEach(function (el, i) {
const canonical_nname = el.getAttribute("href").replace(/^nation=/, "");
if (members_array.includes(canonical_nname)) {
el.parentNode.parentNode.classList.add("rces-cl-cardgardens");
} else {
el.parentNode.parentNode.classList.remove("rces-cl-cardgardens");
}
});
document.querySelectorAll("a.nlink:not(.rces-cl-cardgardens-parsed)").forEach(function (el, i) {
const canonical_nname = el.getAttribute("href").replace(/^nation=/, "");
if (members_array.includes(canonical_nname)) {
const new_el = document.createElement("span");
new_el.classList.add("rces-cl-cardgardens-inline");
el.parentNode.insertBefore(new_el, el);
el.classList.add("rces-cl-cardgardens-parsed");
}
});
};
if (document.getElementById("auctiontablebox")) {
// If we haven't updated in the last 12h
if ((await GM.getValue("cardgardens-lastupdate", 0)) + 12 * 60 * 60 * 1000 < new Date().getTime()) {
GM.xmlHttpRequest({
method: "GET",
url: "https://docs.google.com/spreadsheets/d/1mqQRESG_HrMF6aToHqUF40eHNkLE6XbusoeZHFUMTKQ/export?format=tsv&id=1mqQRESG_HrMF6aToHqUF40eHNkLE6XbusoeZHFUMTKQ&gid=641340461",
onload: async function (data) {
console.info("updated");
await GM.setValue(
"cardgardens",
data.responseText
.split("\n")
.map((x) => x.split("\t")[1].trim().toLowerCase().replace(/ /g, "_"))
.slice(1)
.join("\n")
);
GM.setValue("cardgardens-lastupdate", new Date().getTime());
update_auctiontable();
},
});
}
update_auctiontable();
let observer = new MutationObserver(function (mutationList) {
update_auctiontable();
});
const observerOptions = {
subtree: true,
childList: true,
};
observer.observe(document.getElementById("auctiontablebox"), observerOptions);
GM_addStyle(`
.rces-cl-cardgardens {
background-repeat: no-repeat;
}
tr > td.rces-cl-cardgardens:nth-child(1) {
background-image: linear-gradient(90deg, rgba(255,255,255,0), rgb(255,255,255) 50px, rgba(255,255,255,0) 100px), url('${icon_base64}');
background-position: left;
}
tr > td.rces-cl-cardgardens:nth-child(5) {
background-image: linear-gradient(270deg, rgba(255,255,255,0), rgb(255,255,255) 50px, rgba(255, 255, 255, 0) 100px), url('${icon_base64}');
background-position: right;
}
.rces-cl-cardgardens-inline {
background-repeat: no-repeat;
background-image: url('${icon_base64}');
background-size: contain;
padding-left: 1.5em;
}
`);
}
})();