Skip to content

Commit

Permalink
1.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
bradp committed Mar 30, 2023
1 parent ac86dcc commit b2da906
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 12 deletions.
62 changes: 53 additions & 9 deletions mh-spring-egg-hunt-helper.user.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// ==UserScript==
// @name 🐭️ MouseHunt - Spring Egg Hunt Helper
// @version 1.2.4
// @version 1.2.5
// @description Make the Spring Egg Hunt / Eggscavator interface better.
// @license MIT
// @author bradp
// @namespace bradp
// @match https://www.mousehuntgame.com/*
// @icon https://i.mouse.rip/mouse.png
// @grant none
// @require https://cdn.jsdelivr.net/npm/mousehunt-utils@1.3.0/mousehunt-utils.js
// @require https://cdn.jsdelivr.net/npm/mousehunt-utils@1.4.0/mousehunt-utils.js
// @run-at document-end
// ==/UserScript==

Expand Down Expand Up @@ -1013,6 +1013,10 @@
return egg.is_found;
};

const isScrambles = () => {
return getSetting('seh-scrambles', 'scrambles', false);
};

const makeAquireSection = (title, content, appendTo = null, type = null) => {
const wrapper = document.createElement('div');

Expand Down Expand Up @@ -1586,6 +1590,35 @@
}
};

const doScrambles = async () => {
const resp = await doRequest('managers/ajax/users/userInventory.php', {
action: 'get_items',
'item_types[]': ['spring_chick_message_item'],
});

if (! (resp && resp.items && resp.items.length)) {
return false;
}

const scrambles = createPopup({
title: resp.items[ 0 ].name,
content: resp.items[ 0 ].message,
hasCloseButton: true,
template: 'singleItemLeft',
show: false,
});

scrambles.setAttributes({
className: resp.items[ 0 ].type
});

scrambles.addToken('{*items*}', {
0: resp.items[ 0 ]
}, 'imgArray');

scrambles.show();
};

/**
* Get a random egg image.
*
Expand Down Expand Up @@ -1618,17 +1651,21 @@
item.id = 'mh-custom-icon-egg';

item.addEventListener('click', () => {
changeEggImage();
if (isScrambles()) {
doScrambles();
} else {
changeEggImage();
}
});

// TODO: maybe enable this?
// item.addEventListener('dblclick', () => {
// bookPopup();
// });

const icon = document.createElement('img');
icon.id = 'mh-egg-icon';
icon.src = getRandomEggImage();
if (isScrambles()) {
icon.src = 'https://i.mouse.rip/scrambles.png';
} else {
icon.src = getRandomEggImage();
}

icon.alt = 'Spring Egg Hunt Helper';

item.appendChild(icon);
Expand Down Expand Up @@ -1667,5 +1704,12 @@
'Track collected/uncollected by whether or not they\'re in your inventory.'
);

addSetting(
'SEH Helper: Scrambles',
'seh-scrambles',
false,
'Replace the random egg icon with Scrambles.'
);

createLarryWelcomePopup();
}());
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mh-spring-egg-hunt-helper",
"version": "1.2.4",
"version": "1.2.5",
"description": "",
"main": "mh-spring-egg-hunt-helper.user.js",
"scripts": {
Expand Down

0 comments on commit b2da906

Please sign in to comment.