Skip to content

Commit 37634d2

Browse files
committed
Merge branch 'CherryMellonTree/main'
2 parents 5bcc002 + 163e4f3 commit 37634d2

File tree

1 file changed

+74
-34
lines changed

1 file changed

+74
-34
lines changed

mh-spring-egg-hunt-helper.user.js

Lines changed: 74 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name 🐭️ MouseHunt - Spring Egg Hunt Helper
3-
// @version 1.5.0
3+
// @version 1.5.2
44
// @description Make the Spring Egg Hunt / Eggscavator interface better.
55
// @license MIT
66
// @author bradp
@@ -482,7 +482,7 @@
482482

483483
// Removed backgrounds
484484
'2011_spring_hunt_egg_6': 'https://i.mouse.rip/2011-spring-hunt.png',
485-
black_widow_egg_convertible: 'https://i.mouse.rip/black-widow-egg.png',
485+
black_widow_egg_convertible: 'https://i.mouse.rip/egg-black-widow.png',
486486
caring_egg_convertible: 'https://i.mouse.rip/caring-egg.png',
487487
friendly_egg_convertible: 'https://i.mouse.rip/friendly-egg.png',
488488
ful_mina_egg_convertible: 'https://i.mouse.rip/ful-mina-egg.png',
@@ -877,7 +877,7 @@
877877
.egg-close {
878878
position: absolute;
879879
bottom: 50px;
880-
left: 288px;
880+
left: 138px;
881881
width: 168px;
882882
height: 63px;
883883
font-size: 17px;
@@ -895,6 +895,27 @@
895895
text-decoration: none;
896896
}
897897
898+
.egg-export {
899+
position: absolute;
900+
bottom: 50px;
901+
left: 438px;
902+
width: 168px;
903+
height: 63px;
904+
font-size: 11px;
905+
font-weight: 700;
906+
line-height: 51px;
907+
color: #d7eecb;
908+
text-align: center;
909+
text-shadow: 1px 1px 2px #1a2502;
910+
background-image: url(https://www.mousehuntgame.com/images/ui/hud/folklore_forest_region/dialog/continue_button_frame.png?asset_cache_version=2);
911+
background-position: 0 100%;
912+
}
913+
914+
.egg-export:hover,
915+
.egg-export:focus {
916+
text-decoration: none;
917+
}
918+
898919
.egg-filter,
899920
.egg-back-button {
900921
color: #b0833d;
@@ -1232,23 +1253,23 @@
12321253
const aquireListWrapper = makeElement('div', 'aqure-list-wrapper');
12331254
let tipShown = false;
12341255

1235-
if (ways[ egg.type ] !== undefined) {
1236-
if (ways[ egg.type ].text !== undefined) {
1237-
makeAquireSection(egg, '', [ways[ egg.type ].text], aquireListWrapper, 'tip');
1256+
if (ways[egg.type] !== undefined) {
1257+
if (ways[egg.type].text !== undefined) {
1258+
makeAquireSection(egg, '', [ways[egg.type].text], aquireListWrapper, 'tip');
12381259
tipShown = true;
12391260
}
12401261
}
12411262

1242-
if (ways[ egg.type ] !== undefined) {
1243-
if (Array.isArray(ways[ egg.type ].mice)) {
1244-
makeAquireSection(egg, 'Can be dropped from:', ways[ egg.type ].mice, aquireListWrapper, 'mice');
1263+
if (ways[egg.type] !== undefined) {
1264+
if (Array.isArray(ways[egg.type].mice)) {
1265+
makeAquireSection(egg, 'Can be dropped from:', ways[egg.type].mice, aquireListWrapper, 'mice');
12451266
} else if (! tipShown) {
1246-
makeAquireSection(egg, '', [ways[ egg.type ]], aquireListWrapper, 'tip');
1267+
makeAquireSection(egg, '', [ways[egg.type]], aquireListWrapper, 'tip');
12471268
}
12481269
}
12491270

1250-
if (environments[ egg.type ] !== undefined && environments[ egg.type ].length > 0) {
1251-
makeAquireSection(egg, 'Can be found in:', environments[ egg.type ], aquireListWrapper, 'location');
1271+
if (environments[egg.type] !== undefined && environments[egg.type].length > 0) {
1272+
makeAquireSection(egg, 'Can be found in:', environments[egg.type], aquireListWrapper, 'location');
12521273
}
12531274

12541275
wrapper.appendChild(aquireListWrapper);
@@ -1272,7 +1293,7 @@
12721293
backButton.classList.remove('egg-back-button-hidden');
12731294
}
12741295

1275-
const egg = eggsData[ eggType ];
1296+
const egg = eggsData[eggType];
12761297

12771298
const detailsWrapper = makeElement('div', 'book-right-side');
12781299
const detailHeader = makeElement('div', 'right-header');
@@ -1291,9 +1312,8 @@
12911312
description.classList.add('seh-image-saved-hidden');
12921313

12931314
const descriptionImage = document.createElement('img');
1294-
if (eggImages[ egg.type ]) {
1295-
descriptionImage.src = eggImages[ egg.type ];
1296-
descriptionImage.setAttribute('crossorigin', 'anonymous');
1315+
if (eggImages[egg.type]) {
1316+
descriptionImage.src = eggImages[egg.type];
12971317
} else {
12981318
descriptionImage.src = egg.thumb;
12991319
}
@@ -1355,18 +1375,18 @@
13551375
eggs.environments.forEach((environment) => {
13561376
if (environment.egg_types.length > 0) {
13571377
environment.egg_types.forEach((eggType) => {
1358-
if (environments[ eggType ] !== undefined) {
1359-
environments[ eggType ].push(environment);
1378+
if (environments[eggType] !== undefined) {
1379+
environments[eggType].push(environment);
13601380
} else {
1361-
environments[ eggType ] = [environment];
1381+
environments[eggType] = [environment];
13621382
}
13631383
});
13641384
}
13651385
});
13661386

13671387
// Deduplicate environments
13681388
Object.keys(environments).forEach((eggType) => {
1369-
environments[ eggType ] = [...new Set(environments[ eggType ])];
1389+
environments[eggType] = [...new Set(environments[eggType])];
13701390
});
13711391

13721392
// sort eggs.eggs alphabetically
@@ -1395,7 +1415,7 @@
13951415
const itemWrapperImage = makeElement('div', 'egg-wrapper-image');
13961416

13971417
const eggImage = document.createElement('img');
1398-
eggImage.src = eggImages[ egg.type ] || egg.thumb;
1418+
eggImage.src = eggImages[egg.type] || egg.thumb;
13991419
eggImage.alt = egg.name;
14001420

14011421
const eggName = document.createElement('span');
@@ -1411,7 +1431,7 @@
14111431
itemAction.href = '#';
14121432
itemAction.classList.add('find-egg');
14131433
itemAction.setAttribute('data-type', egg.type);
1414-
eggsData[ egg.type ] = egg;
1434+
eggsData[egg.type] = egg;
14151435

14161436
itemAction.innerText = 'View Details →';
14171437

@@ -1456,31 +1476,31 @@
14561476
const categoryWrapper = makeElement('div', 'category-wrapper');
14571477

14581478
const categoryTitle = makeElement('h4', 'category-title');
1459-
categoryTitle.innerText = eggs.categories[ categoryKey ].name;
1479+
categoryTitle.innerText = eggs.categories[categoryKey].name;
14601480

14611481
categoryWrapper.appendChild(categoryTitle);
14621482

14631483
const categorySubTitle = makeElement('h5', 'category-subtitle');
1464-
categorySubTitle.innerText = eggs.categories[ categoryKey ].description;
1484+
categorySubTitle.innerText = eggs.categories[categoryKey].description;
14651485

14661486
categoryWrapper.appendChild(categorySubTitle);
14671487

14681488
const categoryEggs = makeElement('div', 'category-eggs');
14691489

1470-
eggs.categories[ categoryKey ].egg_types.forEach((eggType) => {
1490+
eggs.categories[categoryKey].egg_types.forEach((eggType) => {
14711491
const eggWrapper = makeElement('div', 'category-egg-wrapper');
14721492
const eggLink = makeElement('a', 'egg-action');
14731493
eggLink.href = '#';
14741494
eggLink.classList.add('welcome-egg-action');
14751495

14761496
const eggImage = makeElement('img', 'category-egg-image');
1477-
eggImage.src = eggImages[ eggsData[ eggType ].type ] || eggsData[ eggType ].thumb;
1497+
eggImage.src = eggImages[eggsData[eggType].type] || eggsData[eggType].thumb;
14781498

14791499
eggLink.setAttribute('data-type', eggType);
14801500

1481-
eggLink.setAttribute('title', eggsData[ eggType ].name);
1501+
eggLink.setAttribute('title', eggsData[eggType].name);
14821502

1483-
if (! isFound(eggsData[ eggType ])) {
1503+
if (! isFound(eggsData[eggType])) {
14841504
eggWrapper.classList.add('egg-wrapper-unfound');
14851505
}
14861506

@@ -1699,6 +1719,21 @@
16991719
}
17001720
};
17011721

1722+
function createExportRow(egg) {
1723+
return `${egg.name}\t${egg.quantity > 0 ? 1 : 0}`;
1724+
}
1725+
1726+
function exportAllMyData() {
1727+
let fullOutput = '';
1728+
Object.values(eggsData).forEach((egg) => {
1729+
fullOutput += createExportRow(egg) + '\n';
1730+
});
1731+
1732+
navigator.clipboard.writeText(fullOutput)
1733+
.then(() => console.log('Copied to clipboard:\n')) // eslint-disable-line no-console
1734+
.catch((err) => console.error('Failed to copy text: ', err)); // eslint-disable-line no-console
1735+
}
1736+
17021737
const bookPopup = async () => {
17031738
popup = new jsDialog();
17041739
popup.setTemplate('ajax');
@@ -1736,10 +1771,15 @@
17361771
${leftWrapper.outerHTML}
17371772
${rightSideFull.outerHTML}
17381773
<a href="#" class="halloweenBoilingCauldronRecipeView-doneButton egg-close" onclick="activejsDialog.hide(); return false;">Close</a>
1774+
<a href="#" id="egg-export-button" class="halloweenBoilingCauldronRecipeView-doneButton egg-export">Copy to clipboard</a>
17391775
</div>`);
17401776

17411777
popup.show();
17421778

1779+
document.getElementById('egg-export-button').addEventListener('click', function () {
1780+
exportAllMyData(eggs);
1781+
});
1782+
17431783
addEggShowAction();
17441784
addSearchAction();
17451785
addFilterAction();
@@ -1786,19 +1826,19 @@
17861826
}
17871827

17881828
const scrambles = createPopup({
1789-
title: resp.items[ 0 ].name,
1790-
content: resp.items[ 0 ].message,
1829+
title: resp.items[0].name,
1830+
content: resp.items[0].message,
17911831
hasCloseButton: true,
17921832
template: 'singleItemLeft',
17931833
show: false,
17941834
});
17951835

17961836
scrambles.setAttributes({
1797-
className: resp.items[ 0 ].type
1837+
className: resp.items[0].type
17981838
});
17991839

18001840
scrambles.addToken('{*items*}', {
1801-
0: resp.items[ 0 ]
1841+
0: resp.items[0]
18021842
}, 'imgArray');
18031843

18041844
scrambles.show();
@@ -1810,7 +1850,7 @@
18101850
* @return {string} The URL of the egg image.
18111851
*/
18121852
const getRandomEggImage = () => {
1813-
return Object.values(eggImages)[ Math.floor(Math.random() * Object.values(eggImages).length) ];
1853+
return Object.values(eggImages)[Math.floor(Math.random() * Object.values(eggImages).length)];
18141854
};
18151855

18161856
/**
@@ -1989,7 +2029,7 @@
19892029
e.preventDefault();
19902030
const scale = e.deltaY > 0 ? 0.9 : 1.1;
19912031
const transform = icon.style.transform;
1992-
const scaleValue = transform ? transform.match(/scale\((\d+\.?\d*)\)/)[ 1 ] : 1;
2032+
const scaleValue = transform ? transform.match(/scale\((\d+\.?\d*)\)/)[1] : 1;
19932033
let newScale = scaleValue * scale;
19942034

19952035
// don't let it get too big or too small

0 commit comments

Comments
 (0)