Extension for HeroWarsHelper script
// ==UserScript==
// @name HWHHideButtonsExt
// @name:en HWHHideButtonsExt
// @name:ru HWHHideButtonsExt
// @namespace HWHHideButtonsExt
// @version 1.4
// @description Extension for HeroWarsHelper script
// @description:en Extension for HeroWarsHelper script
// @description:ru Расширение для скрипта HeroWarsHelper
// @author Green
// @license Copyright Green
// @icon https://i.ibb.co/xtmhK7zS/icon.png
// @match https://www.hero-wars.com/*
// @match https://apps-1701433570146040.apps.fbsbx.com/*
// @run-at document-start
// ==/UserScript==
(function () {
if (!this.HWHClasses) {
console.log('%cObject for extension not found', 'color: red');
return;
}
console.log('%cStart Extension ' + GM_info.script.name + ', v' + GM_info.script.version + ' by ' + GM_info.script.author, 'color: red');
const { addExtentionName } = HWHFuncs;
addExtentionName(GM_info.script.name, GM_info.script.version, GM_info.script.author);
const { buttons, othersPopupButtons, i18nLangData} = HWHData;
const { popup, confShow, setSaveVal, getSaveVal, I18N, getCheckBoxes } = HWHFuncs;
const i18nLangDataEn = {
HIDE_BUTTONS: 'Hide buttons',
HIDE_BUTTONS_TITLE: 'Hide selected buttons in the "Others" section',
HB_SELECT_BUTTONS:
'Select the buttons to hide <br>' +
'<span style="color: green;"><br> The game will restart automatically</span>',
HB_APPLY: 'apply',
HB_OTHERS_SETTINGS: `<span style="color: LightGray;"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor" style="width: 25px;height: 25px;"><path d="M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z"></path></svg></span>`,
};
i18nLangData['en'] = Object.assign(i18nLangData['en'], i18nLangDataEn);
const i18nLangDataRu = {
HIDE_BUTTONS: 'Скрыть кнопки',
HIDE_BUTTONS_TITLE: 'Скрыть выбранные кнопки в разделе "Разное"',
HB_SELECT_BUTTONS:
'Выберите скрываемые кнопки <br> ' +
'<span style="color: green;"> Игра перезагрузится автоматически </span>',
HB_APPLY: 'Применить',
HB_OTHERS_SETTINGS: `<span style="color: LightGray;"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor" style="width: 25px;height: 25px;"><path d="M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z"></path></svg> </span>`,
};
i18nLangData['ru'] = Object.assign(i18nLangData['ru'], i18nLangDataRu);
document.addEventListener('DOMContentLoaded', () => {
const style = document.createElement('style');
style.innerText = `.scriptMenu_otherButton {width: 114px;}`;
document.head.appendChild(style);
});
//Замена кнопки "Разное"
buttons['doOthers'] = {
isCombine: true,
combineList: [
{
get name() {
return I18N('OTHERS');
},
get title() {
return I18N('OTHERS_TITLE');
},
onClick: async function () {
await makeListOfButtons();
},
classes: ['scriptMenu_otherButton']
},
{
get name() {
if (scriptInfo.version >= 2.398){
return I18N('HB_OTHERS_SETTINGS');
}
return '⚙️';
},
get title() {
return I18N('HIDE_BUTTONS_TITLE');
},
onClick: async function () {
await selectButtons();
},
},
],
};
async function makeListOfButtons() {
let { othersPopupButtons } = HWHData;
let hideSelectedButtons = null;
const hideSelectedButtonsString = localStorage.getItem('hideSelectedButtons');
if (hideSelectedButtonsString) {
hideSelectedButtons = JSON.parse(hideSelectedButtonsString);
}
let buttonLanguage = null;
const buttonLanguageString = localStorage.getItem('buttonLanguage');
if (buttonLanguageString) {
buttonLanguage = JSON.parse(buttonLanguageString);
}
let changedGameLanguage = false;
if (buttonLanguage != I18N('HIDE_BUTTONS')) {
changedGameLanguage = true;
}
let newOthersPopupButtons = othersPopupButtons;
console.log(newOthersPopupButtons);
if (hideSelectedButtons && !changedGameLanguage) {
for (let button of hideSelectedButtons) {
if (button.checked == true) {
newOthersPopupButtons = newOthersPopupButtons.filter((e) => e.msg != button.name);
}
}
}
newOthersPopupButtons.push({ result: false, isClose: true });
const answer = await popup.confirm(`${I18N('CHOOSE_ACTION')}:`, newOthersPopupButtons);
if (typeof answer === 'function') {
answer();
}
}
async function selectButtons() {
let hideSelectedButtons = null;
const hideSelectedButtonsString = localStorage.getItem('hideSelectedButtons');
if (hideSelectedButtonsString) {
hideSelectedButtons = JSON.parse(hideSelectedButtonsString)
}
let buttonLanguage = null;
const buttonLanguageString = localStorage.getItem('buttonLanguage');
if (buttonLanguageString) {
buttonLanguage = JSON.parse(buttonLanguageString)
}
let changedGameLanguage = false;
if (buttonLanguage != I18N('HIDE_BUTTONS')) {
changedGameLanguage = true;
}
//Пересобираем список чекбоксов
if (hideSelectedButtons && !changedGameLanguage){
let newSelectedButtons = [];
for (let button of othersPopupButtons) {
if (!button.result) {
continue;
}
let newButton = true;
for (let b of hideSelectedButtons) {
if (button.msg == b.name) {
newSelectedButtons.push({
name:button.msg,
label: button.msg,
title: button.title,
checked: b.checked,
});
newButton = false;
break;
}
}
if (newButton) {
newSelectedButtons.push({
name:button.msg,
label: button.msg,
title: button.title,
checked: false,
});
}
}
hideSelectedButtons = newSelectedButtons;
}
//Впервые собираем или пересобираем все чекбоксы если изменен язык игры
if (!hideSelectedButtons || changedGameLanguage){
console.log("Впервые собираем или пересобираем все кнопки");
hideSelectedButtons = [];
for (let button of othersPopupButtons) {
if (!button.result ) {
continue;
}
hideSelectedButtons.push({
name:button.msg,
label: button.msg,
title: button.title,
checked: false,
});
}
}
let answer = await popup.confirm(
I18N('HB_SELECT_BUTTONS'),
[
{ msg: I18N('HB_APPLY'), result: true, color: 'green' },
{ msg: I18N('BTN_CANCEL'), result: false, isCancel: true, color: 'red' },
],
hideSelectedButtons
);
if (!answer) {
return;
}
const taskList = popup.getCheckBoxes();
for (let button of taskList) {
hideSelectedButtons[taskList.indexOf(button)].checked = button.checked;
}
localStorage.setItem('hideSelectedButtons', JSON.stringify(hideSelectedButtons));
localStorage.setItem('buttonLanguage', JSON.stringify(I18N('HIDE_BUTTONS')));
//Перезагрузить игру
location.reload();
}
})();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址