|
1 | 1 | // ==UserScript== |
2 | 2 | // @name 🐭️ MouseHunt - Spring Egg Hunt Helper |
3 | | -// @version 1.5.0 |
| 3 | +// @version 1.5.2 |
4 | 4 | // @description Make the Spring Egg Hunt / Eggscavator interface better. |
5 | 5 | // @license MIT |
6 | 6 | // @author bradp |
|
482 | 482 |
|
483 | 483 | // Removed backgrounds |
484 | 484 | '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', |
486 | 486 | caring_egg_convertible: 'https://i.mouse.rip/caring-egg.png', |
487 | 487 | friendly_egg_convertible: 'https://i.mouse.rip/friendly-egg.png', |
488 | 488 | ful_mina_egg_convertible: 'https://i.mouse.rip/ful-mina-egg.png', |
|
877 | 877 | .egg-close { |
878 | 878 | position: absolute; |
879 | 879 | bottom: 50px; |
880 | | - left: 288px; |
| 880 | + left: 138px; |
881 | 881 | width: 168px; |
882 | 882 | height: 63px; |
883 | 883 | font-size: 17px; |
|
895 | 895 | text-decoration: none; |
896 | 896 | } |
897 | 897 |
|
| 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 | +
|
898 | 919 | .egg-filter, |
899 | 920 | .egg-back-button { |
900 | 921 | color: #b0833d; |
|
1232 | 1253 | const aquireListWrapper = makeElement('div', 'aqure-list-wrapper'); |
1233 | 1254 | let tipShown = false; |
1234 | 1255 |
|
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'); |
1238 | 1259 | tipShown = true; |
1239 | 1260 | } |
1240 | 1261 | } |
1241 | 1262 |
|
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'); |
1245 | 1266 | } else if (! tipShown) { |
1246 | | - makeAquireSection(egg, '', [ways[ egg.type ]], aquireListWrapper, 'tip'); |
| 1267 | + makeAquireSection(egg, '', [ways[egg.type]], aquireListWrapper, 'tip'); |
1247 | 1268 | } |
1248 | 1269 | } |
1249 | 1270 |
|
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'); |
1252 | 1273 | } |
1253 | 1274 |
|
1254 | 1275 | wrapper.appendChild(aquireListWrapper); |
|
1272 | 1293 | backButton.classList.remove('egg-back-button-hidden'); |
1273 | 1294 | } |
1274 | 1295 |
|
1275 | | - const egg = eggsData[ eggType ]; |
| 1296 | + const egg = eggsData[eggType]; |
1276 | 1297 |
|
1277 | 1298 | const detailsWrapper = makeElement('div', 'book-right-side'); |
1278 | 1299 | const detailHeader = makeElement('div', 'right-header'); |
|
1291 | 1312 | description.classList.add('seh-image-saved-hidden'); |
1292 | 1313 |
|
1293 | 1314 | 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]; |
1297 | 1317 | } else { |
1298 | 1318 | descriptionImage.src = egg.thumb; |
1299 | 1319 | } |
|
1355 | 1375 | eggs.environments.forEach((environment) => { |
1356 | 1376 | if (environment.egg_types.length > 0) { |
1357 | 1377 | 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); |
1360 | 1380 | } else { |
1361 | | - environments[ eggType ] = [environment]; |
| 1381 | + environments[eggType] = [environment]; |
1362 | 1382 | } |
1363 | 1383 | }); |
1364 | 1384 | } |
1365 | 1385 | }); |
1366 | 1386 |
|
1367 | 1387 | // Deduplicate environments |
1368 | 1388 | Object.keys(environments).forEach((eggType) => { |
1369 | | - environments[ eggType ] = [...new Set(environments[ eggType ])]; |
| 1389 | + environments[eggType] = [...new Set(environments[eggType])]; |
1370 | 1390 | }); |
1371 | 1391 |
|
1372 | 1392 | // sort eggs.eggs alphabetically |
|
1395 | 1415 | const itemWrapperImage = makeElement('div', 'egg-wrapper-image'); |
1396 | 1416 |
|
1397 | 1417 | const eggImage = document.createElement('img'); |
1398 | | - eggImage.src = eggImages[ egg.type ] || egg.thumb; |
| 1418 | + eggImage.src = eggImages[egg.type] || egg.thumb; |
1399 | 1419 | eggImage.alt = egg.name; |
1400 | 1420 |
|
1401 | 1421 | const eggName = document.createElement('span'); |
|
1411 | 1431 | itemAction.href = '#'; |
1412 | 1432 | itemAction.classList.add('find-egg'); |
1413 | 1433 | itemAction.setAttribute('data-type', egg.type); |
1414 | | - eggsData[ egg.type ] = egg; |
| 1434 | + eggsData[egg.type] = egg; |
1415 | 1435 |
|
1416 | 1436 | itemAction.innerText = 'View Details →'; |
1417 | 1437 |
|
|
1456 | 1476 | const categoryWrapper = makeElement('div', 'category-wrapper'); |
1457 | 1477 |
|
1458 | 1478 | const categoryTitle = makeElement('h4', 'category-title'); |
1459 | | - categoryTitle.innerText = eggs.categories[ categoryKey ].name; |
| 1479 | + categoryTitle.innerText = eggs.categories[categoryKey].name; |
1460 | 1480 |
|
1461 | 1481 | categoryWrapper.appendChild(categoryTitle); |
1462 | 1482 |
|
1463 | 1483 | const categorySubTitle = makeElement('h5', 'category-subtitle'); |
1464 | | - categorySubTitle.innerText = eggs.categories[ categoryKey ].description; |
| 1484 | + categorySubTitle.innerText = eggs.categories[categoryKey].description; |
1465 | 1485 |
|
1466 | 1486 | categoryWrapper.appendChild(categorySubTitle); |
1467 | 1487 |
|
1468 | 1488 | const categoryEggs = makeElement('div', 'category-eggs'); |
1469 | 1489 |
|
1470 | | - eggs.categories[ categoryKey ].egg_types.forEach((eggType) => { |
| 1490 | + eggs.categories[categoryKey].egg_types.forEach((eggType) => { |
1471 | 1491 | const eggWrapper = makeElement('div', 'category-egg-wrapper'); |
1472 | 1492 | const eggLink = makeElement('a', 'egg-action'); |
1473 | 1493 | eggLink.href = '#'; |
1474 | 1494 | eggLink.classList.add('welcome-egg-action'); |
1475 | 1495 |
|
1476 | 1496 | 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; |
1478 | 1498 |
|
1479 | 1499 | eggLink.setAttribute('data-type', eggType); |
1480 | 1500 |
|
1481 | | - eggLink.setAttribute('title', eggsData[ eggType ].name); |
| 1501 | + eggLink.setAttribute('title', eggsData[eggType].name); |
1482 | 1502 |
|
1483 | | - if (! isFound(eggsData[ eggType ])) { |
| 1503 | + if (! isFound(eggsData[eggType])) { |
1484 | 1504 | eggWrapper.classList.add('egg-wrapper-unfound'); |
1485 | 1505 | } |
1486 | 1506 |
|
|
1699 | 1719 | } |
1700 | 1720 | }; |
1701 | 1721 |
|
| 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 | + |
1702 | 1737 | const bookPopup = async () => { |
1703 | 1738 | popup = new jsDialog(); |
1704 | 1739 | popup.setTemplate('ajax'); |
|
1736 | 1771 | ${leftWrapper.outerHTML} |
1737 | 1772 | ${rightSideFull.outerHTML} |
1738 | 1773 | <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> |
1739 | 1775 | </div>`); |
1740 | 1776 |
|
1741 | 1777 | popup.show(); |
1742 | 1778 |
|
| 1779 | + document.getElementById('egg-export-button').addEventListener('click', function () { |
| 1780 | + exportAllMyData(eggs); |
| 1781 | + }); |
| 1782 | + |
1743 | 1783 | addEggShowAction(); |
1744 | 1784 | addSearchAction(); |
1745 | 1785 | addFilterAction(); |
|
1786 | 1826 | } |
1787 | 1827 |
|
1788 | 1828 | 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, |
1791 | 1831 | hasCloseButton: true, |
1792 | 1832 | template: 'singleItemLeft', |
1793 | 1833 | show: false, |
1794 | 1834 | }); |
1795 | 1835 |
|
1796 | 1836 | scrambles.setAttributes({ |
1797 | | - className: resp.items[ 0 ].type |
| 1837 | + className: resp.items[0].type |
1798 | 1838 | }); |
1799 | 1839 |
|
1800 | 1840 | scrambles.addToken('{*items*}', { |
1801 | | - 0: resp.items[ 0 ] |
| 1841 | + 0: resp.items[0] |
1802 | 1842 | }, 'imgArray'); |
1803 | 1843 |
|
1804 | 1844 | scrambles.show(); |
|
1810 | 1850 | * @return {string} The URL of the egg image. |
1811 | 1851 | */ |
1812 | 1852 | 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)]; |
1814 | 1854 | }; |
1815 | 1855 |
|
1816 | 1856 | /** |
|
1989 | 2029 | e.preventDefault(); |
1990 | 2030 | const scale = e.deltaY > 0 ? 0.9 : 1.1; |
1991 | 2031 | 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; |
1993 | 2033 | let newScale = scaleValue * scale; |
1994 | 2034 |
|
1995 | 2035 | // don't let it get too big or too small |
|
0 commit comments