-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheldenRingInteractiveMapItemprogression.user.js
More file actions
119 lines (96 loc) · 3.1 KB
/
eldenRingInteractiveMapItemprogression.user.js
File metadata and controls
119 lines (96 loc) · 3.1 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
// ==UserScript==
// @name Elden Ring Interactive Map Item Progression
// @namespace Zabuza
// @description To mark items on the map as completed (using right click)
// @include http*://eldenring.wiki.fextralife.com/file/Elden-Ring/map-*.html*
// @version 1.5
// @require http://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @grant none
// @run-at document-idle
// ==/UserScript==
function addCssRules() {
$('body').append('<style type="text/css">\
.' + completedClassName + ' {\
opacity: 0.3 !important;\
}\
</style>');
}
function buildKey(key) {
return storageKeys.keyIndex + storageKeys[key];
}
function loadStorage() {
var keyOfStorage = buildKey(storageKeys.completedItems);
var value = localStorage.getItem(keyOfStorage);
if (value === null || value === '' || value == 'undefined') {
return;
}
completedItems = new Set(JSON.parse(value));
}
function storeCompletedItems() {
var itemsText = JSON.stringify(Array.from(completedItems));
var keyOfStorage = buildKey(storageKeys.completedItems);
localStorage.setItem(keyOfStorage, itemsText);
}
function toggleItemCompleted(item) {
var identifier = $(item).attr("title");
if (completedItems.has(identifier)) {
$(item).removeClass(completedClassName);
completedItems.delete(identifier);
} else {
$(item).addClass(completedClassName);
completedItems.add(identifier);
}
storeCompletedItems();
}
function applyStatus() {
completedItems.forEach(function(identifier) {
$(".leaflet-marker-icon[title='" + $.escapeSelector(identifier) + "']").addClass(completedClassName);
});
}
function attachHook() {
$("img, div").find(".leaflet-marker-icon").each(function() {
if (!$(this).hasClass(hookAttachedClassName)) {
$(this).addClass(hookAttachedClassName);
$(this).mouseup(function(event) {
var rightClickEvent = 3;
if (event.which == rightClickEvent) {
toggleItemCompleted(this);
}
});
}
});
}
function showAllSymbols() {
$("button#bcat-Show-All").click();
$("span:contains('All')").prev("input.leaflet-control-layers-selector").parent("div").click();
}
function hideSomeSymbols() {
$("button#bcat-Consumables").click();
$("button#bcat-Materials").click();
$("button#bcat-Spiritsprings").click();
$("button#bcat-Summoning_Pool").click();
$('label > div:contains("Consumables")').click();
$('label > div:contains("Materials")').click();
$('label > div:contains("Spiritsprings")').click();
$('label > div:contains("Summoning Pool")').click();
}
function routine() {
loadStorage();
applyStatus();
attachHook();
}
var storageKeys = {};
storageKeys.keyIndex = 'eldenringmap_';
storageKeys.completedItems = 'completedItems';
var completedClassName = 'isCompletedItem';
var hookAttachedClassName = 'hookAttached';
var completedItems = new Set();
addCssRules();
showAllSymbols();
hideSomeSymbols();
loadStorage();
attachHook();
window.setTimeout(routine, 500);
$(".leaflet-control-layers, #map-overground, #map-underground, #map-endgame, #mapSwitch").click(function(e) {
window.setTimeout(routine, 2000);
});