forked from Revadike/SteamWebIntegration
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSteam Web Integration.user.js
More file actions
623 lines (553 loc) · 27.2 KB
/
Steam Web Integration.user.js
File metadata and controls
623 lines (553 loc) · 27.2 KB
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
// ==UserScript==
// @author Revadike
// @connect bartervg.com
// @connect steam-tracker.com
// @connect store.steampowered.com
// @contributor Barter.vg
// @contributor Black3ird
// @contributor Lex
// @contributor Luckz
// @description Check every web page for game, dlc and package links to the steam store and mark using icons whether it's owned, unowned, wishlisted, ignored (not interested), DLC, removed/delisted (decommissioned), has low confidence metric, has cards, or is bundled.
// @downloadURL https://github.com/Revadike/SteamWebIntegration/raw/master/Steam%20Web%20Integration.user.js
// @exclude /^https?\:\/\/(.+.steampowered|steamcommunity).com\/(?!groups\/groupbuys).*/
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_info
// @grant GM_openInTab
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_xmlhttpRequest
// @grant unsafeWindow
// @homepageURL https://www.steamgifts.com/discussion/y9vVm/
// @icon https://store.steampowered.com/favicon.ico
// @include /^https?\:\/\/.+/
// @name Steam Web Integration
// @namespace Royalgamer06
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @require https://raw.githubusercontent.com/kapetan/jquery-observe/master/jquery-observe.js
// @run-at document-start
// @supportURL https://github.com/Revadike/SteamWebIntegration/issues/
// @updateURL https://github.com/Revadike/SteamWebIntegration/raw/master/Steam%20Web%20Integration.user.js
// @version 1.9.5
// ==/UserScript==
// ==Code==
(() => {
// eslint-disable-next-line no-multi-assign
this.$ = this.jQuery = jQuery.noConflict(true);
let settings;
let boxNode;
function displaySettings() {
const { name, version, author } = GM_info.script;
$(`#title`).text(`${name} (${version}) by ${author}`);
$(`#settings`).show();
$(`#notinstalled`).hide();
Object.keys(settings).forEach((setting) => {
const value = settings[setting];
if (typeof value === `boolean`) {
$(`#${setting}`).prop(`checked`, value);
} else {
$(`#${setting}`).val(value);
}
});
}
function showToast() {
$(`#snackbar`).addClass(`show`);
setTimeout(() => $(`#snackbar`).removeClass(`show`), 3000);
}
function onChange(elem) {
const name = $(elem).attr(`name`);
const val = $(elem).val();
if (elem.type === `checkbox`) {
settings[name] = $(elem).prop(`checked`);
} else {
settings[elem.name] = Number.isFinite(val) ? parseInt(val, 10) : val;
}
GM_setValue(`swi_settings`, JSON.stringify(settings));
showToast();
}
function createBoxNode() {
return $(`<div/>`, {
"class": `swi-block${settings.boxed ? ` boxed` : ``}`
});
}
function getIconHTML(color, str, lcs, icon, link) {
const { name, version, author } = GM_info.script;
const titlePlus = `\nLast updated at ${lcs}\n${name} (${version}) by ${author}`;
if (link) {
return `<span title="${str}\n${titlePlus}"><a style="color: ${color} !important;" href="${link}" target="_blank">${icon}</a></span>`;
}
return `<span style="color: ${color} !important;" title="${str} on Steam\n${titlePlus}">${icon}</span>`;
}
function getBoxNode(html, appID, subID) {
const node = boxNode.clone(false, false);
if (subID) {
node.attr(`data-subid`, subID);
} else {
node.attr(`data-appid`, appID);
}
node.html(html);
return node;
}
function refreshDecommissioned(callback) {
if (!settings.wantDecommissioned) {
callback();
return;
}
const cachedDecommissioned = JSON.parse(GM_getValue(`swi_decommissioned`, null));
const lastCachedDecommissioned = GM_getValue(`swi_decommissioned_last`, 0);
if (cachedDecommissioned && Date.now() - lastCachedDecommissioned < settings.decommissionedRefreshInterval * 60000) {
callback(cachedDecommissioned);
return;
}
GM_xmlhttpRequest({
"method": `GET`,
"url": `https://steam-tracker.com/api?action=GetAppListV3`,
"timeout": 30000,
"onload": (response) => {
let json = null;
try {
json = JSON.parse(response.responseText);
if (json.success) {
GM_setValue(`swi_decommissioned`, JSON.stringify(json.removed_apps));
GM_setValue(`swi_decommissioned_last`, Date.now());
}
callback(json.removed_apps);
return;
} catch (error) {
console.log(`[Steam Web Integration] Unable to parse removed steam games data. Using cached data...`, error);
}
callback(cachedDecommissioned);
},
"onerror": () => {
console.log(`[Steam Web Integration] An error occurred while refreshing removed steam games data. Using cached data...`);
callback(cachedDecommissioned);
},
"ontimeout": () => {
console.log(`[Steam Web Integration] It took too long to refresh removed steam games data. Using cached data...`);
callback(cachedDecommissioned);
}
});
}
function refreshDLC(callback) {
if (!settings.wantDLC) {
callback();
return;
}
const cachedDLC = JSON.parse(GM_getValue(`swi_dlc`, null));
const lastCachedDLC = parseInt(GM_getValue(`swi_dlc_last`, 0), 10) || 1;
if (cachedDLC && Object.keys(cachedDLC).length > 7000 && Date.now() - lastCachedDLC < settings.dlcRefreshInterval * 60000) {
callback(cachedDLC);
return;
}
GM_xmlhttpRequest({
"method": `GET`,
"url": `https://bartervg.com/browse/dlc/json/`,
"timeout": 30000,
"onload": (response) => {
let json = null;
try {
json = JSON.parse(response.responseText);
if (Object.keys(json).length > 7000) { // sanity check
GM_setValue(`swi_dlc`, JSON.stringify(json));
GM_setValue(`swi_dlc_last`, Date.now());
}
callback(json);
return;
} catch (error) {
console.log(`[Steam Web Integration] Unable to parse Barter.vg downloadable content data. Using cached data...`, error);
}
callback(cachedDLC);
},
"onerror": (response) => {
console.log(`[Steam Web Integration] An error occurred while refreshing Barter.vg downloadable content data. Using cached data...`, response);
callback(cachedDLC);
},
"ontimeout": () => {
console.log(`[Steam Web Integration] It took too long to refresh Barter.vg downloadable content data. Using cached data...`);
callback(cachedDLC);
}
});
}
function refreshLimited(callback) {
if (!settings.wantLimited) {
callback();
return;
}
const cachedLimited = JSON.parse(GM_getValue(`swi_limited`, null));
const lastCachedLimited = parseInt(GM_getValue(`swi_limited_last`, 0), 10) || 1;
if (cachedLimited && Object.keys(cachedLimited).length > 7000 && Date.now() - lastCachedLimited < settings.limitedRefreshInterval * 60000) {
callback(cachedLimited);
return;
}
GM_xmlhttpRequest({
"method": `GET`,
"url": `https://bartervg.com/browse/tag/481/json/`,
"timeout": 30000,
"onload": (response) => {
let json = null;
try {
json = JSON.parse(response.responseText);
if (Object.keys(json).length > 7000) { // sanity check
GM_setValue(`swi_limited`, JSON.stringify(json));
GM_setValue(`swi_limited_last`, Date.now());
}
callback(json);
return;
} catch (error) {
console.log(`[Steam Web Integration] Unable to parse Barter.vg low confidence metric data. Using cached data...`, error);
}
callback(cachedLimited);
},
"onerror": (response) => {
console.log(`[Steam Web Integration] An error occurred while refreshing Barter.vg low confidence metric data. Using cached data...`, response);
callback(cachedLimited);
},
"ontimeout": () => {
console.log(`[Steam Web Integration] It took too long to refresh Barter.vg low confidence metric data. Using cached data...`);
callback(cachedLimited);
}
});
}
function refreshCards(callback) {
if (!settings.wantCards) {
callback();
return;
}
const cachedCards = JSON.parse(GM_getValue(`swi_tradingcards`, null));
const lastCachedCards = parseInt(GM_getValue(`swi_tradingcards_last`, 0), 10) || 1;
if (cachedCards && Object.keys(cachedCards).length > 7000 && Object.values(cachedCards)[0].marketable && Date.now() - lastCachedCards < settings.cardsRefreshInterval * 60000) {
callback(cachedCards);
return;
}
GM_xmlhttpRequest({
"method": `GET`,
"url": `https://bartervg.com/browse/cards/json/`,
"timeout": 30000,
"onload": (response) => {
let json = null;
try {
json = JSON.parse(response.responseText);
if (Object.keys(json).length > 7000) { // sanity check
GM_setValue(`swi_tradingcards`, JSON.stringify(json));
GM_setValue(`swi_tradingcards_last`, Date.now());
}
callback(json);
return;
} catch (error) {
console.log(`[Steam Web Integration] Unable to parse Barter.vg trading cards data. Using cached data...`, error);
}
callback(cachedCards);
},
"onerror": (response) => {
console.log(`[Steam Web Integration] An error occurred while refreshing Barter.vg trading cards data. Using cached data...`, response);
callback(cachedCards);
},
"ontimeout": () => {
console.log(`[Steam Web Integration] It took too long to refresh Barter.vg trading cards data. Using cached data...`);
callback(cachedCards);
}
});
}
function refreshBundles(callback) {
if (!settings.wantBundles) {
callback();
return;
}
const cachedBundles = JSON.parse(GM_getValue(`swi_bundles`, null));
const lastCachedBundles = parseInt(GM_getValue(`swi_bundles_last`, 0), 10) || 1;
if (cachedBundles && Object.keys(cachedBundles).length > 7000 && Object.values(cachedBundles)[0].bundles && Date.now() - lastCachedBundles < settings.bundlesRefreshInterval * 60000) {
callback(cachedBundles);
return;
}
GM_xmlhttpRequest({
"method": `GET`,
"url": `https://bartervg.com/browse/bundles/json/`,
"timeout": 30000,
"onload": (response) => {
let json = null;
try {
json = JSON.parse(response.responseText);
if (Object.keys(json).length > 7000) { // sanity check
GM_setValue(`swi_bundles`, JSON.stringify(json));
GM_setValue(`swi_bundles_last`, Date.now());
}
callback(json);
return;
} catch (error) {
console.log(`[Steam Web Integration] Unable to parse Barter.vg bundles data. Using cached data...`, error);
}
callback(cachedBundles);
},
"onerror": (response) => {
console.log(`[Steam Web Integration] An error occurred while refreshing Barter.vg bundles data. Using cached data...`, response);
callback(cachedBundles);
},
"ontimeout": () => {
console.log(`[Steam Web Integration] It took too long to refresh Barter.vg bundles data. Using cached data...`);
callback(cachedBundles);
}
});
}
function doApp(elem, wishlist, ownedApps, ignoredApps, decommissioned, limited, cards, bundles, dlc, lcs, dlcs, dlclcs, llcs, clcs, blcs) {
$(elem).addClass(`swi`);
const attr = settings.attributes.find((a) => /apps?\//g.test($(elem).attr(a)));
const attrVal = $(elem).attr(attr);
const appID = parseInt(attrVal.match(/apps?\/[0-9]+/g)[0].split(/apps?\//)[1], 10);
if (Number.isNaN(appID)) {
return;
}
setTimeout(() => {
let html;
let subject;
if (dlc && dlc[appID]) {
subject = `DLC`;
} else if (!dlc) {
subject = `Game or DLC`;
} else {
subject = `Game`;
}
if (ownedApps && ownedApps.includes(appID)) { // if owned
html = getIconHTML(settings.ownedColor, `${subject} (${appID}) owned`, lcs, settings.ownedIcon); // ✔
} else if (wishlist.includes(appID)) { // if not owned and wishlisted
html = getIconHTML(settings.wishlistColor, `${subject} (${appID}) wishlisted`, lcs, settings.wishlistIcon); // ❤
} else { // else not owned and not wishlisted
html = getIconHTML(settings.unownedColor, `${subject} (${appID}) not owned`, lcs, settings.unownedIcon); // ✘
}
if (settings.wantIgnores && ignoredApps && ignoredApps.includes(appID)) { // if ignored and enabled
html += getIconHTML(settings.ignoredColor, `${subject} (${appID}) ignored`, llcs, settings.ignoredIcon); // 🛇
}
if (settings.wantDLC && dlc && dlc[appID]) { // if DLC and enabled
const base = dlc[appID].base_appID;
const ownsBase = ownedApps.includes(base);
html += getIconHTML(settings.dlcColor, `${subject} (${appID}) is downloadable content for an ${ownsBase ? `` : `un`}owned base game (${base})`, dlclcs, settings.dlcIcon); // ⇩
}
if (settings.wantDecommissioned && decommissioned) { // if decommissioned and have cache or new data
const app = decommissioned.find((obj) => obj.appid === appID.toString());
if (app) { // if decommissioned?
html += getIconHTML(settings.decommissionedColor, `The ${app.type} '${app.name.replace(/"|'/g, ``)}' (${appID}) is ${app.category.toLowerCase()} and has only ${app.count} confirmed owner${app.count === 1 ? `` : `s`} on Steam`, dlcs, settings.decommissionedIcon, `https://steam-tracker.com/app/${appID}/`); // 🗑
}
}
if (settings.wantLimited && limited && limited[appID]) { // if is limited
html += getIconHTML(settings.limitedColor, `Game (${appID}) has profile features limited`, llcs, settings.limitedIcon); // ⚙
}
if (settings.wantCards && cards && cards[appID] && cards[appID].cards && cards[appID].cards > 0) { // if has cards and enabled
html += getIconHTML(settings.cardColor, `Game (${appID}) has ${cards[appID].cards} ${cards[appID].marketable ? `` : `un`}marketable card${cards[appID].cards === 1 ? `` : `s`}`, clcs, settings.cardIcon, `https://www.steamcardexchange.net/index.php?gamepage-appid-${appID}`);
}
if (settings.wantBundles && bundles && bundles[appID] && bundles[appID].bundles && bundles[appID].bundles > 0) { // if is bundled and enabled
html += getIconHTML(settings.bundleColor, `Game (${appID}) has been in ${bundles[appID].bundles} bundle${bundles[appID].bundles === 1 ? `` : `s`}`, blcs, settings.bundleIcon, `https://barter.vg/steam/app/${appID}/#bundles`);
}
if (settings.prefix) {
$(elem).before(getBoxNode(html, appID));
} else {
$(elem).after(getBoxNode(html, appID));
}
$(elem).parent().css(`overflow`, `visible`);
}, 0);
}
function doSub(elem, ownedPackages, lcs) {
$(elem).addClass(`swi`);
const subID = parseInt(elem.href.match(/sub\/[0-9]+/g)[0].split(`sub/`)[1], 10);
if (Number.isNaN(subID)) {
return;
}
setTimeout(() => {
let html;
if (ownedPackages.includes(subID)) { // if owned
html = getIconHTML(settings.ownedColor, `Package (${subID}) owned`, lcs, settings.ownedIcon); // ✔
} else { // else not owned
html = getIconHTML(settings.unownedColor, `Package (${subID}) not owned`, lcs, settings.unownedIcon); // ✖
}
if (settings.prefix) {
$(elem).before(getBoxNode(html, undefined, subID));
} else {
$(elem).after(getBoxNode(html, undefined, subID));
}
$(elem).parent().css(`overflow`, `visible`);
}, 0);
}
function integrate(userdata, decommissioned, cards, bundles, limited, dlc, lastCached) {
const ignoredApps = Object.keys(userdata.rgIgnoredApps).map((a) => parseInt(a, 10));
const ownedApps = userdata.rgOwnedApps;
const ownedPackages = userdata.rgOwnedPackages;
const wishlist = userdata.rgWishlist;
const lcs = settings.dateOverride ? (new Date(lastCached)).toLocaleString(`sv-SE`) : (new Date(lastCached)).toLocaleString();
const dlcs = (new Date(GM_getValue(`swi_decommissioned_last`, 0))).toLocaleString(settings.dateOverride ? `sv-SE` : undefined);
const dlclcs = (new Date(GM_getValue(`swi_dlc_last`, 0))).toLocaleString(settings.dateOverride ? `sv-SE` : undefined);
const llcs = (new Date(GM_getValue(`swi_limited_last`, 0))).toLocaleString(settings.dateOverride ? `sv-SE` : undefined);
const clcs = (new Date(GM_getValue(`swi_tradingcards_last`, 0))).toLocaleString(settings.dateOverride ? `sv-SE` : undefined);
const blcs = (new Date(GM_getValue(`swi_bundles_last`, 0))).toLocaleString(settings.dateOverride ? `sv-SE` : undefined);
const appSelector = [
`[href*="steamcommunity.com/app/"]`,
`[href*="steamdb.info/app/"]`,
`[href*="store.steampowered.com/agecheck/app/"]`,
`[href*="store.steampowered.com/app/"]`,
`[style*="cdn.akamai.steamstatic.com/steam/apps/"]`,
`[style*="cdn.edgecast.steamstatic.com/steam/apps/"]`,
`[style*="steamcdn-a.akamaihd.net/steam/apps/"]`,
`[style*="steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/"]`,
`[style*="steamcdn-a.opskins.media/steam/apps/"]`,
`[style*="steamcdn-a.opskins.media/steamcommunity/public/images/apps/"]`,
`[style*="steamdb.info/static/camo/apps/"]`,
`img[src*="cdn.akamai.steamstatic.com/steam/apps/"]`,
`img[src*="cdn.edgecast.steamstatic.com/steam/apps/"]`,
`img[src*="steamcdn-a.akamaihd.net/steam/apps/"]`,
`img[src*="steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/"]`,
`img[src*="steamcdn-a.opskins.media/steam/apps/"]`,
`img[src*="steamcdn-a.opskins.media/steamcommunity/public/images/apps/"]`,
`img[src*="steamdb.info/static/camo/apps/"]`
].filter((s) => settings.attributes.find((a) => s.includes(`[${a}`))).map((s) => `${s}:not(.swi)`).join(`, `);
const subSelector = [
`[href*="steamdb.info/sub/"]`,
`[href*="store.steampowered.com/sub/"]`
].map((s) => `${s}:not(.swi)`).join(`, `);
let delaySWI;
const doSWI = (delay = 750) => {
if (delaySWI) {
clearTimeout(delaySWI);
}
delaySWI = setTimeout(() => {
if (settings.dynamicContent !== `ping`) {
console.log(`[Steam Web Integration] Executing`);
}
clearTimeout(delaySWI);
$(appSelector, document.body).get().forEach((elem) => doApp(elem, wishlist, ownedApps, ignoredApps, decommissioned, limited, cards, bundles, dlc, lcs, dlcs, dlclcs, llcs, clcs, blcs));
$(subSelector, document.body).get().forEach((elem) => doSub(elem, ownedPackages, lcs), 0);
}, delay);
};
const clearSWI = () => {
console.log(`[Steam Web Integration] Clearing`);
$(`.swi-block`).remove();
$(`.swi`).removeClass(`swi`);
};
const reloadSWI = () => {
clearSWI();
doSWI(0);
};
$(document).ready(() => {
doSWI(0);
GM_registerMenuCommand(`Run again`, () => doSWI(0));
GM_registerMenuCommand(`Clear all`, clearSWI);
GM_registerMenuCommand(`Clear and run (reload)`, reloadSWI);
unsafeWindow.doSWI = doSWI;
unsafeWindow.clearSWI = clearSWI;
unsafeWindow.reloadSWI = reloadSWI;
if (settings.dynamicContent === `disabled`) {
return;
}
if (settings.dynamicContent === `observe`) {
$(`body`).observe({ "added": true, "attributes": true, "attributeFilter": settings.attributes }, appSelector, () => doSWI());
$(`body`).observe({ "added": true, "attributes": true, "attributeFilter": [`href`] }, subSelector, () => doSWI());
} else if (settings.dynamicContent === `ping`) {
setInterval(doSWI, 1500);
}
});
}
function refresh() {
const cachedJson = GM_getValue(`swi_data`, null);
let lastCached = GM_getValue(`swi_last`, 0);
if (cachedJson && Date.now() - lastCached < settings.userRefreshInterval * 60000) {
const userdata = JSON.parse(cachedJson);
refreshDecommissioned((decommissioned) => refreshDLC((dlc) => refreshLimited((limited) => refreshCards((cards) => refreshBundles((bundles) => integrate(userdata, decommissioned, cards, bundles, limited, dlc, lastCached))))));
return;
}
GM_xmlhttpRequest({
"method": `GET`,
"url": `https://store.steampowered.com/dynamicstore/userdata/?t=${Date.now()}`,
"onload": (response) => {
let userdata = JSON.parse(response.responseText);
if (userdata.rgOwnedApps.length === 0 && userdata.rgOwnedPackages.length === 0 && userdata.rgIgnoredApps.length === 0 && userdata.rgWishlist.length === 0) { // not logged in
if (!cachedJson) {
console.log(`[Steam Web Integration] No cached information available. Please login to Steam to fix this.`);
return;
}
userdata = JSON.parse(cachedJson);
} else {
lastCached = Date.now();
GM_setValue(`swi_last`, lastCached);
GM_setValue(`swi_data`, JSON.stringify(userdata));
}
refreshDecommissioned((decommissioned) => refreshDLC((dlc) => refreshLimited((limited) => refreshCards((cards) => refreshBundles((bundles) => integrate(userdata, decommissioned, cards, bundles, limited, dlc, lastCached))))));
}
});
}
function init() {
const settingsuri = `https://revadike.com/swi/settings`;
const defaults = {
"attributes": [`href`, `src`, `style`],
"boxed": true,
"bundleColor": `#ffff00`,
"bundleIcon": `🎁︎`,
"bundlesRefreshInterval": 2880,
"cardColor": `#0000ff`,
"cardIcon": `🂡`,
"cardsRefreshInterval": 2880,
"dateOverride": false,
"decommissionedColor": `#ffffff`,
"decommissionedIcon": `☠`,
"decommissionedRefreshInterval": 1440,
"dlcColor": `#a655b2`,
"dlcIcon": `⇩`,
"dlcRefreshInterval": 1440,
"dynamicContent": `observe`,
"ignoredColor": `#808080`,
"ignoredIcon": `🚫︎`,
"limitedColor": `#00ffff`,
"limitedIcon": `⚙`,
"limitedRefreshInterval": 2880,
"ownedColor": `#008000`,
"ownedIcon": `✔`,
"prefix": false,
"unownedColor": `#ff0000`,
"unownedIcon": `✘`,
"userRefreshInterval": 1,
"wantBundles": true,
"wantCards": true,
"wantDecommissioned": true,
"wantDLC": true,
"wantIgnores": true,
"wantLimited": true,
"wishlistColor": `#ff69b4`,
"wishlistIcon": `❤`
};
const stylesheet = `
.swi-block {
display: inline-block;
line-height: initial;
}
.swi-block.boxed {
background: rgba(0, 0, 0, 0.7);
border-radius: 5px;
margin: auto 4px auto 4px;
padding: 2px 4px 2px 4px;
position: relative;
}
.swi-block span {
cursor: help;
margin: 2px;
}
.swi-block a {
text-decoration: none;
}
`;
settings = JSON.parse(GM_getValue(`swi_settings`, JSON.stringify(defaults)));
Object.keys(defaults).forEach((setting) => {
if (settings[setting] !== undefined) {
return;
}
settings[setting] = defaults[setting];
});
if (unsafeWindow.location.href.startsWith(settingsuri)) {
unsafeWindow.onChange = onChange;
unsafeWindow.scriptInfo = GM_info.script;
unsafeWindow.settings = settings;
$(document).ready(displaySettings);
} else {
boxNode = createBoxNode();
GM_addStyle(stylesheet);
GM_registerMenuCommand(`Change settings`, () => unsafeWindow.open(settingsuri, `_blank`));
refresh();
}
}
init();
})();
// ==/Code==