HWHPrestigeExt

HWH extension to do prestige quests

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да инсталирате разширение, като например Tampermonkey .

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като Tampermonkey.

За да инсталирате този скрипт, трябва да имате инсталиран скриптов мениджър.

(Вече имам скриптов мениджър, искам да го инсталирам!)

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

(Вече имам инсталиран мениджър на стиловете, искам да го инсталирам!)

// ==UserScript==
// @name			HWHPrestigeExt
// @name:en			HWHPrestigeExt
// @name:ru			HWHPrestigeExt
// @namespace		HWHPrestigeExt
// @version			0.31
// @description		HWH extension to do prestige quests
// @description:en	HWH extension to do prestige quests
// @description:ru	Расширение HWH для квестов престижа
// @author			vakorg
// @license 		Copyright vakorg
// @homepage		none
// @icon			https://zingery.ru/scripts/VaultBoyIco16.ico
// @icon64			https://zingery.ru/scripts/VaultBoyIco64.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 {
		setProgress,
		hideProgress,
		getSaveVal,
		setSaveVal,
		popup,
        I18N,
		Events,
	} = HWHFuncs;

Events.on('startGame', (r) => {
    const style = document.createElement('style');
    style.innerText = `.scriptMenu_dmkMissionButton > .PopUp_btnPlate {display: unset; height: unset;}`;
    document.head.appendChild(style);
});

let {buttons,i18nLangData} = HWHData;

let ruLang ={
    PRESTIGE_HUNT: 'Престиж',
    PRESTIGE_HUNT_TITLE: 'Сделать задания престижа',
	PRESTIGE_HUNT_SETUP: '⚙️',
    PRESTIGE_HUNT_SETUP_TITLE: 'Настройки престижа',

}
let enLang ={
    FRAGMENT_HUNT: 'Spend Stamina',

}
Object.assign(i18nLangData.ru, ruLang)
Object.assign(i18nLangData.en, enLang)
this.HWHData.i18nLangData = i18nLangData;

const PrestigeButton = {
    PrestigeButton: {
		isCombine: true,
		combineList: [
			{
				get name() { return I18N('PRESTIGE_HUNT'); },
				get title() { return I18N('PRESTIGE_HUNT_TITLE'); },
        		onClick: goPrestige,
				hide: false,
				color: 'orange'
			},
			{
        		get name() { return I18N('PRESTIGE_HUNT_SETUP'); },
				get title() { return I18N('PRESTIGE_HUNT_SETUP_TITLE'); },
        		onClick: setupPrestige,
				hide: false,
				color: 'orange'
			},
		]
}}

Object.assign(buttons,PrestigeButton)
this.HWHData.buttons = buttons;


function setupPrestige() {
		let fragment= new Prestige();
		fragment.setup();
}

function goPrestige() {
		let fragment= new Prestige();
		fragment.start();
}

//добавить галочку в "сделать всё"
const task = {
			name: 'gohuntFragment',
			label: I18N('PRESTIGE_HUNT'),
			checked: false
		}
const functions3 = {
		goPrestige
}

const {doYourBest} = HWHClasses;
const doIt = new doYourBest();
	let myfuncList=doIt.funcList
	myfuncList.splice (-3,0,task);
	let myfunctions = doIt.functions
	Object.assign(myfunctions, functions3)

	class extdoYourBest extends doYourBest {
		funcList = myfuncList
		functions = myfunctions
	}
this.HWHClasses.doYourBest = extdoYourBest;


class Prestige {


	prestigeheroTitanGift = false
	TitanArtifactLevelUp = false
    TitanArtifactLevelUpTitanId = 0
    TitanArtifactLevelUpSlotId = -1
    shopBuy = false
    shopBuySlot = 0
    shopBuyFragmentTitanArtifact = 0
    petlevelUpItem = false
    petlevelUpPetId = 0
    arenaAttack = false
    arenaAttackHeroes = ""
    arenaAttackPet = ""
    arenaAttackFavor = ""
    arenaAttackBunner = 0
	buyStamina = false
    questsFarm = false
    heroTitanGiftLevelUp = false
    heroTitanGiftLevelUpHeroId = 0
updateVar(){
	this.TitanArtifactLevelUp = getSaveVal('prestigeTitanArtifactLevelUp', false)
    this.TitanArtifactLevelUpTitanId = getSaveVal('prestigeTitanArtifactLevelUpTitanId', 4020)
    this.TitanArtifactLevelUpSlotId = getSaveVal('prestigeTitanArtifactLevelUpSlotId', 1)
    this.shopBuy = getSaveVal('prestigeShopBuy', false)
    this.shopBuySlot = getSaveVal('prestigeShopBuySlot', 22)
    this.shopBuyFragmentTitanArtifact = getSaveVal('prestigeShopBuyFragmentTitanArtifact', 2003)
    this.petlevelUpItem = getSaveVal('prestigePetlevelUpItem', false)
    this.petlevelUpPetId = getSaveVal('prestigePetlevelUpPetId', 6008)
    this.arenaAttack = getSaveVal('prestigeArenaAttack', false)
    this.arenaAttackHeroes = getSaveVal('prestigeArenaAttackHeroes', "64,13,71,35,70")
    this.arenaAttackPet = getSaveVal('prestigeArenaAttackPet', "6008")
    this.arenaAttackFavor = getSaveVal('prestigeArenaAttackFavor', "13,6003,35,6001,64,6005,70,6002,71,6008")
    this.arenaAttackBunner = getSaveVal('prestigeArenaAttackBunner', "7")
    this.questsFarm = getSaveVal('prestigeQuestsFarm', true)
    this.heroTitanGiftLevelUp = getSaveVal('prestigeHeroTitanGiftLevelUp', false)
    this.heroTitanGiftLevelUpHeroId = getSaveVal('prestigeHeroTitanGiftLevelUpHeroId', 12)
}
SaveVar(){
 setSaveVal('prestigeTitanArtifactLevelUp', this.TitanArtifactLevelUp)
	 setSaveVal('prestigeTitanArtifactLevelUpTitanId', this.TitanArtifactLevelUpTitanId)
	 setSaveVal('prestigeTitanArtifactLevelUpSlotId', this.TitanArtifactLevelUpSlotId)
	 setSaveVal('prestigeShopBuy', this.shopBuy)
	 setSaveVal('prestigeShopBuySlot', this.shopBuySlot)
	 setSaveVal('prestigeShopBuyFragmentTitanArtifact', this.shopBuyFragmentTitanArtifact)
	 setSaveVal('prestigePetlevelUpItem', this.petlevelUpItem)
	 setSaveVal('prestigePetlevelUpPetId', this.petlevelUpPetId)
	 setSaveVal('prestigeArenaAttack', this.arenaAttack)
	 setSaveVal('prestigeArenaAttackHeroes', this.arenaAttackHeroes)
	 setSaveVal('prestigeArenaAttackPet', this.arenaAttackPet)
	 setSaveVal('prestigeArenaAttackFavor', this.arenaAttackFavor)
	 setSaveVal('prestigeArenaAttackBunner', this.arenaAttackBunner)
	 setSaveVal('prestigeQuestsFarm', this.questsFarm)
     setSaveVal('prestigeHeroTitanGiftLevelUp', this.heroTitanGiftLevelUp)
	 setSaveVal('prestigeHeroTitanGiftLevelUpHeroId', this.heroTitanGiftLevelUpHeroId)
}

async start() {
    this.updateVar()
    let sendQ = []
          const questGetAll = await Caller.send(['questGetAll']);
    		const questsNotFarm = questGetAll.filter((e) => e.state == 1);
     if(this.questsFarm){
        setProgress(I18N('questsFarm'));

		const questsFarm = questGetAll.filter((e) => e.state == 2);
		const IsActive = questsFarm.filter((e) => e.id == 20010000);
        const IsTitanit = questsFarm.filter((e) => e.id == 20010001);

		if (IsActive.length != 0){
		sendQ.push({
				name: 'quest_questsFarm',
				args: {
					questIds: [20010000]
				},
			});}
         	if (IsTitanit.length != 0){
		sendQ.push({
				name: 'quest_questsFarm',
				args: {
					questIds: [20010001]
				},
			});}
    }
    if(this.TitanArtifactLevelUp){
        setProgress(I18N('TitanArtifactLevelUp'));

        const IsTitanArtifact = questsNotFarm.filter((e) => [20000150, 20000151, 20000152, 20000153, 20000154].includes(e.id));
        if (IsTitanArtifact.length != 0){
             sendQ.push(
                 {
    "name": "titanArtifactLevelUp",
    "args": {
        "titanId": this.TitanArtifactLevelUpTitanId,
        "slotId": this.TitanArtifactLevelUpSlotId
    }
}
  )
        }
    }
     if(this.petlevelUpItem){
        setProgress(I18N('petlevelUpItem'));

  const pet_getAll = await Caller.send(['pet_getAll']);

const item = pet_getAll.find(obj => obj.id === this.petlevelUpPetId);
let minSlot = 0;
if (item && item.slots) {
    const values = Object.values(item.slots);

    if (values.length > 0) {
        minSlot = Math.min(...values);

    }
}
        const IsPet = questsNotFarm.filter((e) => [20000100, 20000101, 20000102, 20000103, 20000104].includes(e.id));
        if (IsPet.length != 0 & minSlot>0){
            sendQ.push(
                {
                    name: "pet_levelUpItem",
    "args": {
        "petId": this.petlevelUpPetId,
        "slot": minSlot,
        "paid": false
    }
                })
                sendQ.push(
                {
                    name: "pet_levelUpItem",
    "args": {
        "petId": this.petlevelUpPetId,
        "slot": minSlot,
        "paid": false
    }
                }
                    )
        }
    }

 if(this.shopBuy){
        setProgress(I18N('ShopBuy'));

        const IsShopBuy = questsNotFarm.filter((e) => [20000160, 20000161, 20000162, 20000163, 20000164].includes(e.id));
        if (IsShopBuy.length != 0){
            sendQ.push(
                {
                     "name": "shopBuy",
    "args": {
    "shopId": 13,
    "slot": +this.shopBuySlot,
    "cost": {
        "coin": {
            "18": 12
        }
    },
    "reward": {
        "fragmentTitanArtifact": {
            [this.shopBuyFragmentTitanArtifact]: 1
        }
    },
    "amount": 180
}}
                      )
        }
    }

     if(this.arenaAttack){
             setProgress(I18N('arenaAttack'));
           const IsArenaAttack = questsNotFarm.filter((e) => [10004].includes(e.id));
        if (IsArenaAttack.length != 0){
          const ArenaEnemy = await Caller.send(['arenaFindEnemies']);
         let heros = this.arenaAttackHeroes.split(',');
const arr = this.arenaAttackFavor.split(",");
const Favor = {};

for (let i = 0; i < arr.length; i += 2) {
  Favor[arr[i]] = Number(arr[i + 1]);
}
          sendQ.push(
          {
        "name": "arenaAttack",
        "args": {
            "userId": ArenaEnemy[0].userId,
            "heroes": [
                heros[0],
                heros[1],
                heros[2],
                heros[3],
                heros[4]
            ],
            "pet": this.arenaAttackPet,
            "favor": Favor,
            "banners": [
                this.arenaAttackBunner
            ]
        }
     }
              )
     } }
    if(this.heroTitanGiftLevelUp){
        setProgress(I18N('heroTitanGiftLevelUp'));

        const IsGift = questsNotFarm.filter((e) => [20000030, 20000031, 20000032, 20000033, 20000034].includes(e.id));
        if (IsGift.length != 0){
            sendQ.push({
                  "name": "heroTitanGiftLevelUp",
    "args": {
        "heroId": this.heroTitanGiftLevelUpHeroId
    }
                      })
        sendQ.push({
                  "name": "heroTitanGiftLevelUp",
    "args": {
        "heroId": this.heroTitanGiftLevelUpHeroId
    }
                      })
        sendQ.push({
                  "name": "heroTitanGiftLevelUp",
    "args": {
        "heroId": this.heroTitanGiftLevelUpHeroId
    }
                      })
        sendQ.push({
                  "name": "heroTitanGiftDrop",
    "args": {
        "heroId": this.heroTitanGiftLevelUpHeroId
    }
                      })
    }}
  if (sendQ.length != 0){
      const Res = await Caller.send(sendQ);
  }
        setProgress("Престиж Отправлено: "+sendQ.length);
}
async setup() {

    this.updateVar()
	let buttons0 = []
		 buttons0.push({msg: 'Сохранить', result: "1"})
	buttons0.push({msg: I18N('BTN_CANCEL'), result: false})
	//buttons0.push({result: false, isCancel: true})
	let checkbox = [
        	{
			name: 'questsFarm',
			label: 'questsFarm',
				checked: this.questsFarm
		},
		{
			name: 'TitanArtifactLevelUp',
			label: 'PRESTIGE_TitanArtifactLevelUp' + "\nTitanId:" + this.TitanArtifactLevelUpTitanId + "\nSlotId:" + this.TitanArtifactLevelUpSlotId,
				checked: this.TitanArtifactLevelUp
		},
		{
			name: 'shopBuy',
            	label: 'shopBuy' + "\nSlot:" + this.shopBuySlot + "\nFragmentTitanArtifact:" + this.shopBuyFragmentTitanArtifact,
				checked: this.shopBuy,
		},
        	{
			name: 'petlevelUpItem',
				label: 'petlevelUpItem' + "\npetlevelUpPetId:" + this.petlevelUpPetId,
				checked: this.petlevelUpItem,
		},
        	{
			name: 'arenaAttack',
			label: 'arenaAttack' + "\nHeroes:" + this.arenaAttackHeroes + "\nPet:" + this.arenaAttackPet + "\nFavor:" + this.arenaAttackFavor + "\nBunner:" + this.arenaAttackBunner,
				checked: this.arenaAttack,
		},
        	{
			name: 'heroTitanGiftLevelUp',
			label: 'heroTitanGiftLevelUp' + "\nHeroId:" + this.heroTitanGiftLevelUpHeroId,
				checked: this.heroTitanGiftLevelUp,
		}
	]


     buttons0.push(
                {
                    msg: 'Титан лвл ап Артифакт ИД',
                    default: this.TitanArtifactLevelUpTitanId,
                    isInput: false,
                    result: 'TitanArtifactLevelUpTitanId',
                    color: 'green'
                },
            );

     buttons0.push(
                {
                    msg: 'prestigeTitanArtifactLevelUpSlotId',
                    default: this.TitanArtifactLevelUpSlotId,
                    isInput: false,
                    result: 'TitanArtifactLevelUpSlotId',
                    color: 'green'
                },
            );

     buttons0.push(
                {
                    msg: 'shopBuySlot',
                    default: this.shopBuySlot,
                    isInput: false,
                    result: 'shopBuySlot',
                    color: 'green'
                },
            );

     buttons0.push(
                {
                    msg: 'shopBuyFragmentTitanArtifact',
                    default: this.shopBuyFragmentTitanArtifact,
                    isInput: false,
                    result: 'shopBuyFragmentTitanArtifact',
                    color: 'green'
                },
            );

     buttons0.push(
                {
                    msg: 'petlevelUpPetId',
                    default: this.petlevelUpPetId,
                    isInput: false,
                    result: 'petlevelUpPetId',
                    color: 'green'
                },
            );

     buttons0.push(
                {
                    msg: 'arenaAttackHeroes',
                    default: this.arenaAttackHeroes,
                    isInput: false,
                    result: 'arenaAttackHeroes',
                    color: 'green'
                }
            );
         buttons0.push(
                {
                    msg: 'arenaAttackPet',
                    default: this.arenaAttackPet,
                    result: 'arenaAttackPet',
                    isInput: false,
                    color: 'green'
                }
            );     buttons0.push(
                {
                    msg: 'arenaAttackFavor',
                    default: this.arenaAttackFavor,
                    isInput: false,
                    result: 'arenaAttackFavor',
                    color: 'green'
                }
            );
         buttons0.push(
                {
                    msg: 'arenaAttackBunner',
                    default: this.arenaAttackBunner,
                    result: 'arenaAttackBunner',
                    isInput: false,
                    color: 'green'
                }
            );
          buttons0.push(
                {
                    msg: 'heroTitanGiftLevelUpHeroId',
                    default: this.heroTitanGiftLevelUpHeroId,
                    result: 'heroTitanGiftLevelUpHeroId',
                    isInput: false,
                    color: 'green'
                }
            );
            let answer = await popup.confirm("Настройки", buttons0,checkbox);
    	let chkcvar = popup.getCheckBoxes().find((e) => e.name === 'TitanArtifactLevelUp')?.checked
	this.TitanArtifactLevelUp = chkcvar
    	chkcvar = popup.getCheckBoxes().find((e) => e.name === 'shopBuy')?.checked
	this.shopBuy = chkcvar
    chkcvar = popup.getCheckBoxes().find((e) => e.name === 'petlevelUpItem')?.checked
	this.petlevelUpItem = chkcvar
    chkcvar = popup.getCheckBoxes().find((e) => e.name === 'arenaAttack')?.checked
	this.arenaAttack = chkcvar
        chkcvar = popup.getCheckBoxes().find((e) => e.name === 'questsFarm')?.checked
	this.questsFarm = chkcvar
           chkcvar = popup.getCheckBoxes().find((e) => e.name === 'heroTitanGiftLevelUp')?.checked
	this.heroTitanGiftLevelUp = chkcvar

 if (!answer) {
              return;
	}
    let editVarName = false

    let answer2 = false
 if (answer == 1) {this.SaveVar();
                  return;}
    else{
     editVarName = answer;
        let buttons1 = []
             buttons1.push(
                {
                    msg: editVarName,
                    default: this[editVarName],
                    isInput: true,
                    color: 'green'
                },
            );
        buttons1.push({msg: I18N('BTN_CANCEL'), result: false})
            answer2 = await popup.confirm("Изменить значение", buttons1);
    }

 if (!answer2) {
              return;
	}

this[editVarName] = answer2;
this.SaveVar();
this.setup();


}

}

this.HWHClasses.Prestige = Prestige;
})();