-
Notifications
You must be signed in to change notification settings - Fork 0
/
mh-travel-tweaks.user.js
462 lines (384 loc) · 12.7 KB
/
mh-travel-tweaks.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
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
// ==UserScript==
// @name 🐭️ Mousehunt - Travel Tweaks
// @version 2.4.0
// @description Makes the travel page a bit better.
// @license MIT
// @author bradp
// @namespace bradp
// @match https://www.mousehuntgame.com/*
// @icon https://i.mouse.rip/mouse.png
// @grant none
// @run-at document-end
// @require https://cdn.jsdelivr.net/npm/[email protected]/mousehunt-utils.js
// @require https://cdn.jsdelivr.net/npm/[email protected]
// ==/UserScript==
((function () {
'use strict';
/**
* Expand the travel regions and zoom the map.
*/
const expandTravelRegions = () => {
if ('travel' !== getCurrentPage()) {
return;
}
const hud = document.getElementById('mousehuntHud');
if (hud) {
const hudHeight = hud.offsetHeight + 30;
const map = document.querySelector('.travelPage-mapContainer.full');
if (map) {
map.style.height = `calc(100vh - ${hudHeight}px)`;
}
}
// eslint-disable-next-line no-undef
app.pages.TravelPage.zoomOut();
// eslint-disable-next-line no-undef
app.pages.TravelPage.zoomOut();
const regionHeaders = document.querySelectorAll('.travelPage-regionMenu-regionLink');
if (regionHeaders) {
regionHeaders.forEach((regionHeader) => {
regionHeader.setAttribute('onclick', 'return false;');
});
}
const travelAreas = document.querySelectorAll('.travelPage-regionMenu-item');
if (travelAreas && travelAreas.length > 0) {
travelAreas.forEach((area) => {
area.classList.add('active');
area.classList.remove('contracted');
});
}
const locations = document.querySelectorAll('.travelPage-map-image-environment.active');
if (locations && locations.length > 0) {
locations.forEach((location) => {
location.addEventListener('mouseover', () => {
location.classList.add('highlight');
});
location.addEventListener('mouseout', () => {
setTimeout(() => {
location.classList.remove('highlight');
}, 1000);
});
});
}
};
/**
* Add the tab for Simple Travel.
*/
const addSimpleTravelTab = () => {
if ('travel' !== getCurrentPage()) {
return;
}
const exists = document.getElementById('mh-simple-travel-tab');
if (exists) {
return;
}
const tabContainer = document.querySelector('.mousehuntHud-page-tabHeader-container');
if (! tabContainer) {
return;
}
const tab = document.createElement('a');
tab.id = 'mh-simple-travel-tab';
tab.classList.add('mousehuntHud-page-tabHeader');
tab.setAttribute('data-tab', 'simple-travel');
tab.setAttribute('onclick', 'hg.utils.PageUtil.onclickPageTabHandler(this); return false;');
const tabText = document.createElement('span');
tabText.textContent = 'Simple Travel';
tab.appendChild(tabText);
tabContainer.appendChild(tab);
};
/**
* Add the page for Simple Travel.
*/
const addSimpleTravelPage = () => {
if ('travel' !== getCurrentPage()) {
return;
}
const exists = document.getElementById('mh-simple-travel-page');
if (exists) {
return;
}
const pageContainer = document.querySelector('.mousehuntHud-page-tabContentContainer');
if (! pageContainer) {
return;
}
const page = document.createElement('div');
page.id = 'mh-simple-travel-page';
page.classList.add('mousehuntHud-page-tabContent');
page.classList.add('simple-travel');
page.setAttribute('data-tab', 'simple-travel');
if ('not-set' === getSetting('simple-travel', 'not-set')) {
const settingTip = document.createElement('div');
settingTip.classList.add('travelPage-map-prefix');
settingTip.classList.add('simple-travel-tip');
settingTip.innerHTML = 'You can set this as the default travel tab in your <a href="https://www.mousehuntgame.com/preferences.php?tab=userscript-settings"> Game Settings</a>.';
page.appendChild(settingTip);
}
const regionMenu = document.querySelector('.travelPage-regionMenu');
if (! regionMenu) {
return;
}
const regionMenuClone = regionMenu.cloneNode(true);
const travelLinks = regionMenuClone.querySelectorAll('.travelPage-regionMenu-environmentLink');
if (travelLinks && travelLinks.length > 0) {
travelLinks.forEach((link) => {
link.setAttribute('onclick', 'return false;');
link.addEventListener('click', (event) => {
const environment = event.target.getAttribute('data-environment');
// eslint-disable-next-line no-undef
app.pages.TravelPage.travel(environment);
// eslint-disable-next-line no-undef
hg.utils.PageUtil.setPage('Camp');
return false;
});
});
}
page.appendChild(regionMenuClone);
pageContainer.appendChild(page);
};
/**
* Check the setting and maybe default to Simple Travel.
*/
const maybeSwitchToSimpleTravel = () => {
if ('travel' !== getCurrentPage()) {
return;
}
const defaultTravel = getSetting('simple-travel');
if (! defaultTravel) {
return;
}
// eslint-disable-next-line no-undef
hg.utils.PageUtil.setPageTab('simple-travel');
const mapTab = document.querySelector('.mousehuntHud-page-tabHeader.map');
if (mapTab) {
mapTab.addEventListener('click', () => {
setTimeout(() => {
// eslint-disable-next-line no-undef
app.pages.TravelPage.zoomIn();
// eslint-disable-next-line no-undef
app.pages.TravelPage.zoomIn();
// eslint-disable-next-line no-undef
app.pages.TravelPage.zoomIn();
// eslint-disable-next-line no-undef
app.pages.TravelPage.zoomIn();
// eslint-disable-next-line no-undef
app.pages.TravelPage.zoomOut();
// eslint-disable-next-line no-undef
app.pages.TravelPage.zoomOut();
}, 100);
});
}
};
const addReminders = () => {
let reminderText = '';
let shouldDeactivate = true;
switch (getCurrentLocation()) {
case 'rift_valour':
if (user.quests?.QuestRiftValour?.is_fuel_enabled) {
reminderText = 'Champion\'s Fire is active.';
}
break;
case 'queso_river':
case 'queso_plains':
case 'queso_quarry':
case 'queso_geyser':
if (
user.quests?.QuestQuesoCanyon?.is_wild_tonic_active ||
user.quests?.QuestQuesoGeyser?.is_wild_tonic_enabled
) {
reminderText = 'Wild Tonic is active.';
}
break;
case 'floating_islands':
if ('launch_pad_island' === user.quests?.QuestFloatingIslands?.hunting_site_atts?.island_power_type) {
break;
}
if (
! user.quests?.QuestFloatingIslands?.hunting_site_atts?.is_fuel_enabled && // BW not active.
! (
user.quests?.QuestFloatingIslands?.hunting_site_atts?.is_vault_island && // is SP.
user.quests.QuestFloatingIslands.hunting_site_atts.island_mod_panels[2].is_complete // is on 4th tile.
)
) {
shouldDeactivate = false;
reminderText = 'Bottled Wind is <strong>not</strong> active.';
}
break;
case 'foreword_farm':
case 'prologue_pond':
case 'table_of_contents':
if (user.quests?.QuestProloguePond?.is_fuel_enabled ||
user.quests?.QuestForewordFarm?.is_fuel_enabled ||
user.quests?.QuestTableOfContents?.is_fuel_enabled) {
reminderText = 'Condensed Creativity is active.';
} else {
shouldDeactivate = false;
reminderText = 'Condensed Creativity is <strong>not</strong> active.';
}
break;
}
if (reminderText) {
showHornMessage({
title: shouldDeactivate ? 'Don\'t waste your resources!' : 'Don\'t waste your hunts!',
text: reminderText,
button: 'Dismiss',
dismiss: 4000,
});
// temporary fix for the dismiss timing
setTimeout(() => {
const dismiss = document.querySelector('#mh-custom-horn-message .huntersHornView__messageAction');
if (dismiss) {
dismiss.click();
}
}, 3000);
}
};
/**
* Add the tab & page for Simple Travel.
*/
const addSimpleTravel = () => {
addSimpleTravelTab();
addSimpleTravelPage();
maybeSwitchToSimpleTravel();
};
/**
* Add the settings for Simple Travel.
*/
const addSimpleTravelSetting = () => {
addSetting('Travel Tweaks - Default to simple travel', 'simple-travel', false, 'Use the simple travel page by default.', {}, addSettingsTab());
addSetting('Travel Tweaks - Show travel reminders', 'travel-reminders', true, 'Show reminders about active resources.', {}, addSettingsTab());
};
onPageChange({ change: expandTravelRegions });
expandTravelRegions();
onPageChange({ change: addSimpleTravel });
addSimpleTravel();
onPageChange({ change: addSimpleTravelSetting });
addSimpleTravelSetting();
if (window.location.search.includes('tab=simple-travel')) {
// eslint-disable-next-line no-undef
hg.utils.PageUtil.setPageTab('simple-travel');
}
if (getSetting('travel-reminders', true)) {
onEvent('travel_complete', () => {
setTimeout(() => {
addReminders();
}, 250);
});
}
addStyles(`.travelPage-map-spacer,
.travelPage-map-simpleToggle,
.mousehuntHud-page-tabContent.map.full .travelPage-map-simpleToggle.full,
.mousehuntHud-page-tabContent.map.full .travelPage-map-prefix.full {
display: none;
}
.travelPage-regionMenu {
width: 22%;
overflow: scroll;
}
.travelPage-map-environment-detailContainer {
left: 22%;
width: 78%;
}
.travelPage-regionMenu-environmentLink.active {
color: #000;
background: #a4cafc;
}
.travelPage-regionMenu-stats {
color: #4d4d4d;
background-color: #d8d8d8;
}
.travelPage-regionMenu-numFriends {
padding: 0;
background: none;
}
.travelPage-mapContainer.full {
height: auto;
min-height: 800px;
max-height: 900px;
border: none;
}
.travelPage-map-imageContainer {
width: 78%;
}
.travelPage-map-zoomContainer {
bottom: 300px;
transform: scale(1.5);
}
.travelPage-map-image-environment-name {
top: 70px;
z-index: 15;
font-size: 22px;
font-variant: none;
text-shadow: 1px 1px #000, 0 0 10px #000, 8px 12px 9px #000;
}
.travelPage-map-image-environment.locked .travelPage-map-image-environment-status {
z-index: 1;
opacity: 0.5;
}
.travelPage-map-image-environment-star {
z-index: 10;
}
.travelPage-map-image-environment-button {
top: 100px;
transform: scale(1.2);
}
.travelPage-regionMenu-environmentLink.mystery {
display: inline-block;
color: #9e9e9e;
pointer-events: none;
}
.travelPage-regionMenu-item[data-region="riftopia"] {
display: block !important;
}
.travelPage-regionMenu-item[data-region="riftopia"] .travelPage-regionMenu-item-contents {
display: block !important;
}
.travelPage-regionMenu-regionLink:hover,
.travelPage-regionMenu-regionLink:focus {
cursor: unset;
}
#mh-simple-travel-page .travelPage-map-prefix {
display: block;
}
#mh-simple-travel-page .travelPage-regionMenu {
display: grid;
grid-template-columns: repeat(5, 1fr);
width: 100%;
margin-bottom: 50px;
overflow: visible;
background-color: transparent;
}
#mh-simple-travel-page .travelPage-regionMenu-item {
margin: 1px;
background-color: #e2e2e2;
outline: 1px solid #4c71b4;
}
#mh-simple-travel-page .travelPage-regionMenu-item[data-region="gnawnia"],
#mh-simple-travel-page .travelPage-regionMenu-item[data-region="valour"],
#mh-simple-travel-page .travelPage-regionMenu-item[data-region="whisker_woods"],
#mh-simple-travel-page .travelPage-regionMenu-item[data-region="burroughs"],
#mh-simple-travel-page .travelPage-regionMenu-item[data-region="furoma"] {
min-height: 215px;
}
#mh-simple-travel-page .travelPage-regionMenu-item[data-region="riftopia"] {
min-height: 250px;
}
#mh-simple-travel-page .travelPage-regionMenu-environments {
width: 150px;
box-shadow: none;
}
#mh-simple-travel-page .travelPage-regionMenu-item-contents {
overflow: visible !important;
}
#mh-simple-travel-page .travelPage-regionMenu-environmentLink.active {
color: #4e6081;
}
#mh-simple-travel-page .travelPage-regionMenu-environmentLink:hover,
#mh-simple-travel-page .travelPage-regionMenu-environmentLink:focus {
color: #fff;
background-color: #6383bf;
}
.huntersHornView__messageContent strong {
font-weight: 900;
}
`);
migrateUserscript('🐭️ MouseHunt - Travel Tweaks', 'https://greasyfork.org/en/scripts/452232-mousehunt-travel-tweaks');
})());