forked from tehstone/wayfarer-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wayfarer-nomination-types.user.js
283 lines (253 loc) · 20.1 KB
/
wayfarer-nomination-types.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
// ==UserScript==
// @name Wayfarer Nomination Types
// @version 0.2.0
// @description Shows an indicator for which game you submitted nominations in.
// @namespace https://github.com/tehstone/wayfarer-addons/
// @downloadURL https://github.com/tehstone/wayfarer-addons/raw/main/wayfarer-nomination-types.user.js
// @homepageURL https://github.com/tehstone/wayfarer-addons/
// @match https://wayfarer.nianticlabs.com/*
// ==/UserScript==
// Copyright 2022 tehstone, bilde
// This file is part of the Wayfarer Addons collection.
// This script is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This script is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You can find a copy of the GNU General Public License in the root
// directory of this script's GitHub repository:
// <https://github.com/tehstone/wayfarer-addons/blob/main/LICENSE>
// If not, see <https://www.gnu.org/licenses/>.
/* eslint-env es6 */
/* eslint no-var: "error" */
(() => {
let urlMap;
let counter = 0;
const games = {
ingress: {
icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAAAh1BMVEUAAAAAAABfAOVVAOJgAOBZAOlDALY2AIZSAM9XAORaAONbAOWkdO3////f0PKJROr09PTs5vTm3PTx7/TTvPJkD+fFp+9fBuXNsvKzi+7q4fSsge3Xw/KcYe13J+jh1/K+m++6ku+LTeqqe+1wIOijb+1oGeiCPOqfaO1+N+iPVup3MOjPuvJ4u1X3AAAAC3RSTlMACu65lHAqE0vY10mWW7gAAAYgSURBVHja3Ztpc5swGISTnmklc4RwmcM2YPCR///76kQ2CzoqGwkn7X5oO52JZ+N9YHkl8fCP68fXrz8ePk4/v5GTvv18+Bg9fv9C3vXl++PDB+jpF+n16+nhXkL4ZKS7oYDwmcKQMN0RBYRPQpdSNyb3RQHhx92WnrQ73hUFhH/c0bOK5m4oIPyyoANV90EB4TcHOtZ2Pz8KCD+sqKiinAkFhA/0e218f83lABTshw/0mVJncdIqpRe5MVCYKXygT+vcW7zLyzPKhEsSKFgKX0Q/CRa9ggQotEDBXvgi+mt/MdJMKCB8oI/wIaCASxIo2Agf6CN8SEChaIxRQPhAXwzf6/8ACsgBKBiED/TF8JebZ/bXUoZCFwMFs/DLQhp+EFHKDFAaBRIUdiUBCtPDbw/S8L2XmsIArV89CQqHdgIKCB/oi+E7GaUw8KbMkaHgTkAB4QN9IXxKhwaYpChsj7c/NuK2rw5fZmCEgpPikhRR0IfPFB7k4csNKFGoQg4FXfhQ7MrCVxhQo7DtYqCgC5/TUQxfbUCNQlFqUED4vFwufI0BJQqHVo0CwhcUpnz4agM6FNz47yggfCCwE8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4T++ShWhs9asaZaA5zKRIcCHRX1VrN1i0MlWgPq/UuhErBsQgpN+Ewu9o55/SaQfAdXVQnMXKEJf3SK4fej5gCDHgVUQnKeWRThZ9ypUxxg0B7h0KPQeJgUK134+xhHODSHWK5HIcOs7OrCv+4805MUBV+FQrhcYsn2qvB1J7r0KKQjFA59LEeD8A1QgEqD8A1QgJoJ4ZujADWJQfjmKITZhPCNUYjxdLI0CN8chS6Xhl/pwzdHocSKrUH4RijIw98pw7eNApRQhN+pwp8BBewfVbrwzU94iyhgB61vo0IV/kwoYH7ba8KfDYWk7NtIHf58KDhVb0cd/pwoxIikUYQ/LwqQKvx5UYDU4c+MAqQOf14U7vjmJ1AwDd8chWnh/z8vvX6C134/wYvPH//q9yd4+d2G/gAkMiXZAYCffgAAAABJRU5ErkJggg==',
label: 'Ingress'
},
pogo: {
// https://logos.fandom.com/wiki/Pok%C3%A9mon_Go
icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAAC8VBMVEUAAABaW15aW11ZW15aW15aW15ZWV9bW1taW15aW15aW15bW11aW15aW15aW15aWl5aWl5QUF5aW15aW15aW15aW15ZW15gYGBZW15aW15aW15aWl5aWl1aWlpaW15aXF5aW15aW15aW15aW15bW14II063uL3///8GM3TtHCRaW14MTaILJU+1trwKI06ytbsULVUyR2wyP1Y2SWsoPmOHj58SKlQfMlJ+HzgPKFIWLlhZWl4bMlkkNlNfbYWprLR9h5gwRWhWWV0PKE9seI2vsbhIWHYsQWVITlq55fulqbGMlKJmc4pkcYgmPGJFTVqboKtRYXwqOlQhNFMIOX8/UXA4TG03QlcOIk2srraPlaNveo9NXnoGNnqBiZoIPoiKkqB3gpQKRZMIPIRCVHNETFkuPVUcMFKiprCEjJx0f5NZaIJUZIAMPYBLXHg5TnFDS1oYMFieqLman6oRO3gkOmBSVV1QVFwfNlwYLlEVK1HmHCWepK6XnKh+h5kKQYxda4RcaoMHNHfg4+mirLuZo7SCmLSnqrN0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MZtzIJkQmJcIYKpfLBFTQ/rZDKtfEt+1ABQYX/PBZBKZyeSWzzRHPccP2JCtQwPI+V8P6hNz3FqAGk4uQ2XZCMpsmRmE6n0imSSnRGYEaLN/f2SZ4GLe9+46sK+3bRA5TDKHzaSOUITTWZRiAFp6nt2W1ON40N79xtGS1pT8HmriTSQiNuzCh0TulU1wD51ejMTER+tHA0eAUfz+mdIZ7I5UP4uLWUqTW0jzsjgKDtVpioBFSq++03mfiV4u//s0KVElBZJ8YLC7O43qP9I3YvBYRcSAm1loDtJ5QddMpbtDTEYTY7AN6DBP3AaHw2e8EYFyIoyV2T2p3Lx/J7d3hWUCJjYhykz/GDeIt+EYponhS5PYA6P2IRuksbzBq/1or+dOYJNVCbhTVSS9Q4hVGbRDp/T4jLBwJHAhL31ltUjUuGDwveQucvYjmkcNejgQOh0WBgz8IEiUeInacQc6uvFFhPwmaS0swJlam6TBuZZQiN3lmES9LPIL81hj15DgsclmAA5C5Fu9HUvBgUVNSlII5xhekNDFKUPoMDA5AWilsxSUnERuTqIzM1a0mYpzFjYwiG1EaUTKf3gHJQUPGDuY4VaFTcVl9RkkebTqvJKO+rJgWOh2hhE79QgKVGXalpF7RB8XwQGC2vy4tKyoqK31tN7OfbGWkXl1HdAkYIUO7cdzO3UzSpw1Fyrh7FccNGBv2dyLbcE+537Zl2sZnzzmwOILW2nGD/l6G27e7h+CR16/ZNG2PQuU3bdOalbyH4LF7385TnB5XSD7XbT4dH79pU3z86c3rPCSf83cdR3rLTsLw8MF+iF5nHuYE9OnfuYLrsaOFh8Yt2XWxY9nvxSlL4qDsN6jzheAhwWMGysLnKHXh805R+DxwTHBIl3+CsL6hXRnp99rpAtYy0u+uoX3DuvxLDBkVqi1+Dx01pMt/QY/goUGi/L+bYBbK/8ODhgYHduL/AM4qCHIBv5ZyAAAAAElFTkSuQmCC',
label: 'Pokémon GO'
}
};
// ===== INJECTION AND REQUEST HANDLING =====
(function (open) {
XMLHttpRequest.prototype.open = function (method, url) {
if (method == 'GET') {
let callback = null;
switch (url) {
case '/api/v1/vault/manage':
callback = injectNominations;
break;
case '/api/v1/vault/home':
callback = injectShowcase;
break;
}
if (callback) this.addEventListener('load', () => checkResponse(this.response, callback), false);
}
open.apply(this, arguments);
};
})(XMLHttpRequest.prototype.open);
const checkResponse = (response, callback) => {
try {
const json = JSON.parse(response);
if (!json) return;
if (json.captcha || !json.result) return;
callback(json.result);
} catch (e) {
console.error(e);
}
};
const injectNominations = result => {
urlMap = Object.assign({}, ...result.nominations.map(e => ({[e.id]: e.imageUrl})));
// awaitElement(() => document.querySelector('input.w-full')).then(searchInput => {
// if (searchInput !== undefined) {
// }
// });
window.addEventListener("WFNM_MapFilterChange", renderNominationMapIntegration);
addNominationListIcons();
renderNominationMapIntegration();
setupDetailsPaneInput(result.nominations);
};
const injectShowcase = result => awaitElement(() => document.querySelector('.showcase-item')).then(ref => {
const showcase = result.showcase;
const count = showcase.length;
const labelMap = Object.assign({}, ...Object.keys(games).map(e => ({[games[e].label]: e})));
let index = 0;
let style = null;
const render = () => {
const discGame = showcase[index].discovererGame;
const styleContent = labelMap.hasOwnProperty(discGame) ? `background-image: url(${games[labelMap[discGame]].icon});` : 'display: none;';
if (style) style.parentElement.removeChild(style);
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = `app-showcase-item .showcase-item__image-caption::before { ${styleContent} }`;
document.querySelector('head').appendChild(style);
};
render();
const paginators = document.getElementsByClassName('showcase-gallery__button');
if (paginators.length == 2) {
paginators[0].addEventListener('click', () => { index = (index - 1 + count) % count; render(); });
paginators[1].addEventListener('click', () => { index = (index + 1 + count) % count; render(); });
}
});
// ===== RENDERING FUNCTIONS =====
const addNominationListIcons = () => {
if (localStorage.hasOwnProperty('wfpNominationTypes')) {
const types = JSON.parse(localStorage.wfpNominationTypes);
Object.keys(types).forEach(k => addIcon(k, types[k]));
}
}
const renderNominationMapIntegration = () => awaitElement(() => document.querySelector('.wayfarernm_text')).then(ref => {
if (localStorage.hasOwnProperty('wfpNominationTypes')) {
const types = JSON.parse(localStorage.wfpNominationTypes);
const counters = Object.assign({}, ...Object.keys(games).map(e => ({[e]: 0})));
const existing = document.getElementsByClassName('wfpNT__nmIntegration');
for (let i = existing.length - 1; i >= 0; i--) existing[i].parentNode.removeChild(existing[i]);
const listEl = document.querySelector(".cdk-virtual-scroll-content-wrapper");
nominations = listEl["__ngContext__"][3][26];
let nominationIds = {};
nominations.forEach(n => nominationIds[n.id] = 1);
Object.keys(types).forEach(k => {
if (nominationIds[k]) {
counters[types[k]]++
}
});
Object.keys(games).forEach(game => {
if (counters[game] > 0) {
const outer = document.createElement('span');
outer.classList.add('wfpNT__nmIntegration');
outer.classList.add('wfpNT__nmIntegration_' + game);
outer.textContent = counters[game];
ref.appendChild(outer);
}
});
}
}).catch(() => {});
const setupDetailsPaneInput = nominations => {
let box = null;
const idMap = Object.assign({}, ...nominations.map(e => ({[e.imageUrl]: e.id})));
awaitElement(() => document.querySelector('app-nominations-list')).then(ref => ref.addEventListener('click', e => {
const item = e.target.closest('app-nominations-list-item');
if (item) {
const id = idMap[item.querySelector('img').src];
awaitElement(() => document.querySelector('app-details-pane app-nomination-tag-set')).then(tags => {
const before = tags.parentElement;
if (box) box.parentElement.removeChild(box);
box = document.createElement('p');
box.classList.add('wfpNT__para');
const thisGame = getGameForId(id);
const first = document.createElement('span');
first.textContent = 'Nominated in:';
box.appendChild(first);
Object.keys(games).forEach(game => box.appendChild(createRadioForGame(game, counter, game == thisGame, () => setGameForId(id, game))));
counter++;
before.parentElement.insertBefore(box, before);
});
};
}));
};
const createRadioForGame = (game, uid, checked, callback) => {
const label = document.createElement('label');
label.for = 'wfpNT__radio' + uid + game;
const radio = document.createElement('input');
radio.id = label.for;
radio.type = 'radio';
radio.name = 'wfpNT__radiogroup' + uid;
radio.checked = checked;
radio.addEventListener('change', callback);
const span = document.createElement('span');
span.textContent = games[game].label;
label.appendChild(radio);
label.appendChild(span);
return label;
};
// ===== UTILITY FUNCTIONS =====
const awaitElement = get => new Promise((resolve, reject) => {
let triesLeft = 10;
const queryLoop = () => {
const ref = get();
if (ref) resolve(ref);
else if (!triesLeft) reject();
else setTimeout(queryLoop, 100);
triesLeft--;
}
queryLoop();
});
// ===== STORAGE HANDLING =====
const getGameForId = id => {
if (localStorage.hasOwnProperty('wfpNominationTypes')) {
const types = JSON.parse(localStorage.wfpNominationTypes);
if (types.hasOwnProperty(id)) return types[id];
}
return null;
}
const setGameForId = (id, game) => {
const types = localStorage.hasOwnProperty('wfpNominationTypes') ? JSON.parse(localStorage.wfpNominationTypes) : {};
types[id] = game;
addIcon(id, game);
localStorage.wfpNominationTypes = JSON.stringify(types);
renderNominationMapIntegration();
}
// ===== STYLE INJECTION =====
const addIcon = (id, game) => {
if (!urlMap.hasOwnProperty(id) || !games.hasOwnProperty(game)) return;
const css = `app-nominations-list-item img[src='${urlMap[id]}'] + div app-nomination-tag-set::before {
content: ' ';
background-image: url(${games[game].icon});
background-repeat: no-repeat;
background-size: contain;
display: inline-block;
width: 28px;
}`;
const style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
document.querySelector('head').appendChild(style);
};
(() => {
let css = `
.wfpNT__para {
margin-bottom: 16px;
}
.wfpNT__para input[type=radio] {
margin: 0 3px 0 12px;
}
app-showcase-item .showcase-item__image-caption::before {
content: '';
position: absolute;
left: -44px;
width: 44px;
top: 0;
height: 100%;
background-color: rgba(0,0,0,0.8);
background-size: 40px;
background-repeat: no-repeat;
background-position: right;
}
`;
Object.keys(games).forEach(game => {
css += `.wfpNT__nmIntegration_${game}::before {
content: ' ';
background-image: url(${games[game].icon});
background-repeat: no-repeat;
background-size: contain;
display: inline-block;
width: 28px;
height: 28px;
margin: 0 3px -8px 10px;
}`;
});
const style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
document.querySelector('head').appendChild(style);
})();
})();