From f7cac8c3505688e182a607f12d17fbe2b29ad3fa Mon Sep 17 00:00:00 2001 From: iamc24 <42425100+iamc24@users.noreply.github.com> Date: Sat, 12 Jul 2025 12:44:11 -0700 Subject: [PATCH 01/14] Update debugcheatstools.user.js Fix loading held items and pokedex; Fix region filtering in pokedex --- custom/debugcheatstools.user.js | 47 +++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/custom/debugcheatstools.user.js b/custom/debugcheatstools.user.js index d7a5aef..5bcbe3f 100644 --- a/custom/debugcheatstools.user.js +++ b/custom/debugcheatstools.user.js @@ -5,7 +5,7 @@ // @description Edit your save for debug (currency, gems, pokeballs, pokemons, ...) // @copyright https://github.com/Ephenia // @license GPL-3.0 License -// @version 1.0.3 +// @version 1.0.4 // @homepageURL https://github.com/Ephenia/Pokeclicker-Scripts/ // @supportURL https://github.com/Ephenia/Pokeclicker-Scripts/issues @@ -67,7 +67,7 @@ function filterPkdx(){ case 'all': break; default: - display = tdb.innerHTML.toLowerCase().includes(document.getElementById('pkdxRegionFilter').value); + display = tdb.innerHTML.toLowerCase().substring(0,92).includes(document.getElementById('pkdxRegionFilter').value); break; } } @@ -142,7 +142,7 @@ function loadPkdx(){ let lpkm = App.game.party.getPokemon(pokemon.id); let region = GameConstants.Region[pokemon.nativeRegion].charAt(0).toUpperCase() + GameConstants.Region[pokemon.nativeRegion].slice(1) let hint = ""; - let getPokemonLocation = PokemonHelper.getPokemonLocations(pokemon.name, playerRegion); + let getPokemonLocation = PokemonLocations.getPokemonLocations(pokemon.name, playerRegion); let roadLocations = getPokemonLocation[0] if (roadLocations) { for (let i = 0; i <= playerRegion; i++) { @@ -435,10 +435,46 @@ function initSaveEditor() { } // heldItems - HeldItem.getSortedHeldItems().forEach((itm, idx) => { + HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { const itmPretty = itm.name.replaceAll('_', ' '); modalBody.querySelector('#heldItems').innerHTML += ` -
+
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
${itmPretty}
@@ -451,6 +487,7 @@ function initSaveEditor() { const reg = GameConstants.Region[i] pkdxRegFilt.innerHTML += ``; } + pkdxRegFilt.innerHTML += ''; } /* WIP, sevii helper From 8a33c1cbacdfbe56d8de7c5d566bf221b8383455 Mon Sep 17 00:00:00 2001 From: iamc24 <42425100+iamc24@users.noreply.github.com> Date: Sat, 12 Jul 2025 13:02:43 -0700 Subject: [PATCH 02/14] Update debugcheatstools.user.js Better fix for region filtering --- custom/debugcheatstools.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom/debugcheatstools.user.js b/custom/debugcheatstools.user.js index 5bcbe3f..f904b61 100644 --- a/custom/debugcheatstools.user.js +++ b/custom/debugcheatstools.user.js @@ -67,7 +67,7 @@ function filterPkdx(){ case 'all': break; default: - display = tdb.innerHTML.toLowerCase().substring(0,92).includes(document.getElementById('pkdxRegionFilter').value); + display = tdb.innerHTML.match(/.*<\/td>/g)[1].toLowerCase().includes(document.getElementById('pkdxRegionFilter').value); break; } } From 6a9812a50dfc24b0dedbc1b24ec8d060bfd74169 Mon Sep 17 00:00:00 2001 From: iamc24 <42425100+iamc24@users.noreply.github.com> Date: Mon, 14 Jul 2025 05:22:27 -0700 Subject: [PATCH 03/14] Update debugcheatstools.user.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix Pokédex name filtering being case-sensitive; Fix none being default region filtering option --- custom/debugcheatstools.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom/debugcheatstools.user.js b/custom/debugcheatstools.user.js index f904b61..ebed4bf 100644 --- a/custom/debugcheatstools.user.js +++ b/custom/debugcheatstools.user.js @@ -59,7 +59,7 @@ function filterPkdx(){ let display = true; if (document.getElementById('pkdxNameFilter').value !== ""){ - display = tdb.innerHTML.includes(document.getElementById('pkdxNameFilter').value); + display = tdb.innerHTML.match(/.*<\/td>/g)[3].toLowerCase().includes(document.getElementById('pkdxNameFilter').value.toLowerCase()); } if (display === true) { @@ -487,7 +487,7 @@ function initSaveEditor() { const reg = GameConstants.Region[i] pkdxRegFilt.innerHTML += ``; } - pkdxRegFilt.innerHTML += ''; + pkdxRegFilt.innerHTML += ''; } /* WIP, sevii helper From 5fbd9d4942c17c6493f7b1e01a2dd0079e87bebe Mon Sep 17 00:00:00 2001 From: iamc24 <42425100+iamc24@users.noreply.github.com> Date: Mon, 14 Jul 2025 10:00:34 -0700 Subject: [PATCH 04/14] Update debugcheatstools.user.js Fix currency cheat to allow removing currency with negative numbers in input --- custom/debugcheatstools.user.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/custom/debugcheatstools.user.js b/custom/debugcheatstools.user.js index ebed4bf..41b4ae2 100644 --- a/custom/debugcheatstools.user.js +++ b/custom/debugcheatstools.user.js @@ -52,6 +52,14 @@ function gainPkrs(id){ document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[2].src = getPokerusImgSrc(id, lpkm); } +function gainCurrency(currency) { + if (parseInt(document.getElementById("inputAddCurrency").value || 0) >= 0) { + App.game.wallet.addAmount(new Amount(parseInt(document.getElementById("inputAddCurrency").value || 0),currency),true) + } else if (parseInt(document.getElementById("inputAddCurrency").value || 0) < 0) { + App.game.wallet.loseAmount(new Amount(Math.abs(parseInt(document.getElementById("inputAddCurrency").value || 0)),currency)) + } +} + function filterPkdx(){ let lst = document.querySelectorAll(':scope #pkdx tbody tr'); for (let i = 0; i < lst.length; i++) { @@ -255,7 +263,7 @@ function initSaveEditor() {
-

Click on button to add money (input * achievement bonus)

+

Click on button to add money (input)

@@ -371,7 +379,7 @@ function initSaveEditor() { const itm = GameConstants.Currency[i]; const itmPretty = itm.charAt(0).toUpperCase() + itm.replace(/[A-Z]/g, ' $&').trim().slice(1); modalBody.querySelector('#currency').innerHTML += ` -
+
${itmPretty}
From eb20ab956f4a5dc2fb43443197c3239b2865b01e Mon Sep 17 00:00:00 2001 From: iamc24 <42425100+iamc24@users.noreply.github.com> Date: Thu, 17 Jul 2025 23:13:11 -0700 Subject: [PATCH 05/14] Update debugcheatstools.user.js Improve currency handling --- custom/debugcheatstools.user.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/custom/debugcheatstools.user.js b/custom/debugcheatstools.user.js index 41b4ae2..fecfc86 100644 --- a/custom/debugcheatstools.user.js +++ b/custom/debugcheatstools.user.js @@ -53,10 +53,18 @@ function gainPkrs(id){ } function gainCurrency(currency) { - if (parseInt(document.getElementById("inputAddCurrency").value || 0) >= 0) { - App.game.wallet.addAmount(new Amount(parseInt(document.getElementById("inputAddCurrency").value || 0),currency),true) - } else if (parseInt(document.getElementById("inputAddCurrency").value || 0) < 0) { - App.game.wallet.loseAmount(new Amount(Math.abs(parseInt(document.getElementById("inputAddCurrency").value || 0)),currency)) + let changeAmount = parseInt(document.getElementById("inputAddCurrency").value || 0); + if (changeAmount > 0) { + App.game.wallet.addAmount(new Amount(changeAmount,currency),true); + } else if (changeAmount < 0) { + changeAmount = Math.abs(changeAmount); + if (changeAmount > App.game.wallet.currencies[currency]()) { + changeAmount = App.game.wallet.currencies[currency](); + if (changeAmount == 0) { + return; + } + } + App.game.wallet.loseAmount(new Amount(changeAmount,currency)); } } From 8e5a4593470fa39fa301d197dd2c20fd5879ac12 Mon Sep 17 00:00:00 2001 From: iamc24 <42425100+iamc24@users.noreply.github.com> Date: Fri, 18 Jul 2025 13:09:46 -0700 Subject: [PATCH 06/14] Update debugcheatstools.user.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix Meltan line showing in Pokédex before Alola --- custom/debugcheatstools.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom/debugcheatstools.user.js b/custom/debugcheatstools.user.js index fecfc86..e85c571 100644 --- a/custom/debugcheatstools.user.js +++ b/custom/debugcheatstools.user.js @@ -154,7 +154,7 @@ function loadPkdx(){ pkdxBody.innerHTML = ''; let toAdd = ""; for (const pokemon of pokemonList) { - if (pokemon.nativeRegion <= playerRegion) { + if ((pokemon.nativeRegion <= playerRegion && pokemon.nativeRegion > -1) || (pokemon.nativeRegion == -1 && playerRegion >= GameConstants.Region.alola) || pokemon.id == 0) { let lpkm = App.game.party.getPokemon(pokemon.id); let region = GameConstants.Region[pokemon.nativeRegion].charAt(0).toUpperCase() + GameConstants.Region[pokemon.nativeRegion].slice(1) let hint = ""; From cc9152a61d6af0859e80b45767090e09ecee26e4 Mon Sep 17 00:00:00 2001 From: iamc24 <42425100+iamc24@users.noreply.github.com> Date: Fri, 18 Jul 2025 13:13:59 -0700 Subject: [PATCH 07/14] Update debugcheatstools.user.js (#1) Refactor to make script work in browser; Bump version; Add credits --- custom/debugcheatstools.user.js | 158 +++++++++++++++++++++++++------- 1 file changed, 125 insertions(+), 33 deletions(-) diff --git a/custom/debugcheatstools.user.js b/custom/debugcheatstools.user.js index e85c571..158ef51 100644 --- a/custom/debugcheatstools.user.js +++ b/custom/debugcheatstools.user.js @@ -1,11 +1,11 @@ // ==UserScript== // @name [Pokeclicker] Debug Cheats Tools // @namespace Pokeclicker Scripts -// @author kevingrillet +// @author kevingrillet (Credit: iamc24, ajthompson) // @description Edit your save for debug (currency, gems, pokeballs, pokemons, ...) // @copyright https://github.com/Ephenia // @license GPL-3.0 License -// @version 1.0.4 +// @version 1.1.0 // @homepageURL https://github.com/Ephenia/Pokeclicker-Scripts/ // @supportURL https://github.com/Ephenia/Pokeclicker-Scripts/issues @@ -34,25 +34,32 @@ function getPokeballImgSrc(id, pkm){ } // eslint-disable-next-line no-unused-vars -function gainPk(id){ +function gainPk(){ + let id = parseFloat(this.parentElement.children[0].innerHTML); let lpkm = App.game.party.getPokemon(id); if (!lpkm) App.game.party.gainPokemonById(id) else if (!(lpkm?.shiny === true)) App.game.party.gainPokemonById(id, true); document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[1].src = getPokeballImgSrc(id, lpkm); + filterPkdx(); + loadEventHandlers(); } // eslint-disable-next-line no-unused-vars -function gainPkrs(id){ +function gainPkrs(){ + let id = parseFloat(this.parentElement.children[0].innerHTML); let lpkm = App.game.party.getPokemon(id); if (!lpkm) return; lpkm.effortPoints = ((lpkm.pokerus < 2) ? 1 : 50) * 1000; // strange lpkm.pokerus = (lpkm.pokerus < 2) ? 2 : 3; document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[2].src = getPokerusImgSrc(id, lpkm); + filterPkdx(); + loadEventHandlers(); } -function gainCurrency(currency) { +function gainCurrency() { + let currency = parseInt(this.getAttribute("currency")); let changeAmount = parseInt(document.getElementById("inputAddCurrency").value || 0); if (changeAmount > 0) { App.game.wallet.addAmount(new Amount(changeAmount,currency),true); @@ -156,7 +163,7 @@ function loadPkdx(){ for (const pokemon of pokemonList) { if ((pokemon.nativeRegion <= playerRegion && pokemon.nativeRegion > -1) || (pokemon.nativeRegion == -1 && playerRegion >= GameConstants.Region.alola) || pokemon.id == 0) { let lpkm = App.game.party.getPokemon(pokemon.id); - let region = GameConstants.Region[pokemon.nativeRegion].charAt(0).toUpperCase() + GameConstants.Region[pokemon.nativeRegion].slice(1) + let region = GameConstants.Region[pokemon.nativeRegion].charAt(0).toUpperCase() + GameConstants.Region[pokemon.nativeRegion].slice(1); let hint = ""; let getPokemonLocation = PokemonLocations.getPokemonLocations(pokemon.name, playerRegion); let roadLocations = getPokemonLocation[0] @@ -179,8 +186,8 @@ function loadPkdx(){ ${region} ${pokemon.name} - - + + YES') : '194, 46, 40);">NO'} `; @@ -188,6 +195,7 @@ function loadPkdx(){ } pkdxBody.innerHTML = toAdd; filterPkdx(); + loadEventHandlers(); } function loadQuestLines() { @@ -224,16 +232,97 @@ function loadQuestLines() { qlBody.innerHTML = toAdd; filterQuestLine(); + loadEventHandlers(); } -function initSaveEditor() { - window.gainPk = gainPk; - window.gainPkrs = gainPkrs; - window.loadPkdx = loadPkdx; - window.filterPkdx = filterPkdx; - window.loadQuestLines = loadQuestLines; - window.filterQuestLine = filterQuestLine; +function loadEventHandlers() { + + // currency + for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { + document.getElementById("currency_" + i).addEventListener("click", gainCurrency); + } + // gems + for (let i = 0; i < Gems.nTypes; i++) { + document.getElementById("gems_" + i).addEventListener("click", function () { + App.game.gems.gainGems(parseInt(document.getElementById('inputAddGems').value || 0), parseInt(this.getAttribute("gem"))); + }); + } + + // pokeballs + for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { + document.getElementById("pokeballs_" + i).addEventListener("click", function () { + App.game.pokeballs.gainPokeballs(parseInt(this.getAttribute("pokeball")), parseInt(document.getElementById('inputAddPokeballs').value || 0), true); + }); + } + + // berries + for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { + document.getElementById("berries_" + i).addEventListener("click", function () { + App.game.farming.gainBerry(parseInt(this.getAttribute("berry")), parseInt(document.getElementById('inputAddBerries').value || 0), true); + }); + } + + // evolutionitems + for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { + document.getElementById("evolutionitems_" + i).addEventListener("click", function () { + player.gainItem(ItemList[this.getAttribute("item")].name, parseInt(document.getElementById('inputAddEvolutionItems').value || 0), true); + }); + } + + // vitamins + for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { + document.getElementById("vitamins_" + i).addEventListener("click", function () { + player.gainItem(ItemList[this.getAttribute("vitamin")].name, parseInt(document.getElementById('inputAddVitamins').value || 0), true); + }); + } + + // heldItems + HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { + document.getElementById("attackhelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().attack.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { + document.getElementById("typehelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().typeRestricted.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { + document.getElementById("evhelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().ev.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { + document.getElementById("exphelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().exp.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { + document.getElementById("otherhelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().other.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + + //pokedex events + document.getElementById("pokedex").children[1].addEventListener("click", loadPkdx); + document.getElementById("pkdxNameFilter").addEventListener("input", filterPkdx); + document.getElementById("pkdxRegionFilter").addEventListener("change", filterPkdx); + document.getElementById("pkdxShinyFilter").addEventListener("change", filterPkdx); + document.getElementById("pkdxPKRSFilter").addEventListener("change", filterPkdx); + for (const pokemon of pokemonList) { + let pkElement = document.getElementById("pkdx_" + pokemon.id.toString().replace('.','_')); + if (pkElement){ + pkElement.children[4].addEventListener("click", gainPk); + pkElement.children[5].addEventListener("click", gainPkrs); + } + } + //questline events + document.getElementById("questlines").children[1].addEventListener("click", loadQuestLines); + document.getElementById("questLineFilter").addEventListener("change", filterQuestLine); +} + +function initSaveEditor() { // Add menu item let eventLi = document.createElement('li'); eventLi.innerHTML = `Debug Cheats` @@ -300,21 +389,21 @@ function initSaveEditor() {

You can break your game, please backup!
Do not complete pokedex from another region if you are not in the region you will not be able to go to the next region!

- +
- +
-
- @@ -324,7 +413,7 @@ function initSaveEditor() {
- @@ -349,11 +438,11 @@ function initSaveEditor() {
- +
- @@ -387,7 +476,7 @@ function initSaveEditor() { const itm = GameConstants.Currency[i]; const itmPretty = itm.charAt(0).toUpperCase() + itm.replace(/[A-Z]/g, ' $&').trim().slice(1); modalBody.querySelector('#currency').innerHTML += ` -
+
${itmPretty}
@@ -398,7 +487,7 @@ function initSaveEditor() { for (let i = 0; i < Gems.nTypes; i++) { const itm = PokemonType[i]; modalBody.querySelector('#gems').innerHTML += ` -
+
${itm}
@@ -409,7 +498,7 @@ function initSaveEditor() { for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { const itm = GameConstants.Pokeball[i]; modalBody.querySelector('#pokeballs').innerHTML += ` -
+
${itm}
@@ -420,7 +509,7 @@ function initSaveEditor() { for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { const itm = BerryType[i]; modalBody.querySelector('#berries').innerHTML += ` -
+
${itm}
@@ -432,7 +521,7 @@ function initSaveEditor() { const itm = GameConstants.StoneType[i]; const itmPretty = itm.replaceAll('_', ' '); modalBody.querySelector('#evolutionitems').innerHTML += ` -
+
${itmPretty}
@@ -443,7 +532,7 @@ function initSaveEditor() { for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { const itm = GameConstants.VitaminType[i]; modalBody.querySelector('#vitamins').innerHTML += ` -
+
${itm}
@@ -454,7 +543,7 @@ function initSaveEditor() { HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { const itmPretty = itm.name.replaceAll('_', ' '); modalBody.querySelector('#heldItems').innerHTML += ` -
+
${itmPretty}
@@ -463,7 +552,7 @@ function initSaveEditor() { HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { const itmPretty = itm.name.replaceAll('_', ' '); modalBody.querySelector('#heldItems').innerHTML += ` -
+
${itmPretty}
@@ -472,7 +561,7 @@ function initSaveEditor() { HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { const itmPretty = itm.name.replaceAll('_', ' '); modalBody.querySelector('#heldItems').innerHTML += ` -
+
${itmPretty}
@@ -481,7 +570,7 @@ function initSaveEditor() { HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { const itmPretty = itm.name.replaceAll('_', ' '); modalBody.querySelector('#heldItems').innerHTML += ` -
+
${itmPretty}
@@ -490,7 +579,7 @@ function initSaveEditor() { HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { const itmPretty = itm.name.replaceAll('_', ' '); modalBody.querySelector('#heldItems').innerHTML += ` -
+
${itmPretty}
@@ -504,6 +593,9 @@ function initSaveEditor() { pkdxRegFilt.innerHTML += ``; } pkdxRegFilt.innerHTML += ''; + + + loadEventHandlers(); } /* WIP, sevii helper From 33ec22046d23dd5ef12885d19f6039852a2e6714 Mon Sep 17 00:00:00 2001 From: iamc24 <42425100+iamc24@users.noreply.github.com> Date: Sun, 27 Jul 2025 13:46:04 -0700 Subject: [PATCH 08/14] Update debugcheatstools.user.js Slightly simplify event handler logic for gems, pokeballs, berries; --- custom/debugcheatstools.user.js | 1210 +++++++++++++++---------------- 1 file changed, 605 insertions(+), 605 deletions(-) diff --git a/custom/debugcheatstools.user.js b/custom/debugcheatstools.user.js index 158ef51..7978af6 100644 --- a/custom/debugcheatstools.user.js +++ b/custom/debugcheatstools.user.js @@ -24,592 +24,592 @@ const profileDrop = document.getElementById('startMenu').querySelectorAll('ul li const profileModal = document.getElementById('profileModal'); function getPokerusImgSrc(id, pkm){ - let lpkm = pkm || App.game.party.getPokemon(id); - return lpkm?.pokerus || 0 > 0 ? (lpkm.pokerus === 3 ? "assets/images/breeding/pokerus/Resistant.png" : "assets/images/breeding/pokerus/Contagious.png") : "assets/images/breeding/pokerus/Infected.png"; + let lpkm = pkm || App.game.party.getPokemon(id); + return lpkm?.pokerus || 0 > 0 ? (lpkm.pokerus === 3 ? "assets/images/breeding/pokerus/Resistant.png" : "assets/images/breeding/pokerus/Contagious.png") : "assets/images/breeding/pokerus/Infected.png"; } function getPokeballImgSrc(id, pkm){ - let lpkm = pkm || App.game.party.getPokemon(id); - return lpkm ? ((lpkm?.shiny === true) ? "assets/images/pokeball/Pokeball-shiny.svg" : "assets/images/pokeball/Pokeball.svg") : "assets/images/pokeball/None.svg"; + let lpkm = pkm || App.game.party.getPokemon(id); + return lpkm ? ((lpkm?.shiny === true) ? "assets/images/pokeball/Pokeball-shiny.svg" : "assets/images/pokeball/Pokeball.svg") : "assets/images/pokeball/None.svg"; } // eslint-disable-next-line no-unused-vars function gainPk(){ - let id = parseFloat(this.parentElement.children[0].innerHTML); - let lpkm = App.game.party.getPokemon(id); - if (!lpkm) - App.game.party.gainPokemonById(id) - else if (!(lpkm?.shiny === true)) - App.game.party.gainPokemonById(id, true); - document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[1].src = getPokeballImgSrc(id, lpkm); - filterPkdx(); - loadEventHandlers(); + let id = parseFloat(this.parentElement.children[0].innerHTML); + let lpkm = App.game.party.getPokemon(id); + if (!lpkm) + App.game.party.gainPokemonById(id) + else if (!(lpkm?.shiny === true)) + App.game.party.gainPokemonById(id, true); + document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[1].src = getPokeballImgSrc(id, lpkm); + filterPkdx(); + loadEventHandlers(); } // eslint-disable-next-line no-unused-vars function gainPkrs(){ - let id = parseFloat(this.parentElement.children[0].innerHTML); - let lpkm = App.game.party.getPokemon(id); - if (!lpkm) return; - lpkm.effortPoints = ((lpkm.pokerus < 2) ? 1 : 50) * 1000; // strange - lpkm.pokerus = (lpkm.pokerus < 2) ? 2 : 3; - document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[2].src = getPokerusImgSrc(id, lpkm); - filterPkdx(); - loadEventHandlers(); + let id = parseFloat(this.parentElement.children[0].innerHTML); + let lpkm = App.game.party.getPokemon(id); + if (!lpkm) return; + lpkm.effortPoints = ((lpkm.pokerus < 2) ? 1 : 50) * 1000; // strange + lpkm.pokerus = (lpkm.pokerus < 2) ? 2 : 3; + document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[2].src = getPokerusImgSrc(id, lpkm); + filterPkdx(); + loadEventHandlers(); } function gainCurrency() { - let currency = parseInt(this.getAttribute("currency")); - let changeAmount = parseInt(document.getElementById("inputAddCurrency").value || 0); - if (changeAmount > 0) { - App.game.wallet.addAmount(new Amount(changeAmount,currency),true); - } else if (changeAmount < 0) { - changeAmount = Math.abs(changeAmount); - if (changeAmount > App.game.wallet.currencies[currency]()) { - changeAmount = App.game.wallet.currencies[currency](); - if (changeAmount == 0) { - return; - } - } - App.game.wallet.loseAmount(new Amount(changeAmount,currency)); - } + let currency = parseInt(this.getAttribute("currency")); + let changeAmount = parseInt(document.getElementById("inputAddCurrency").value || 0); + if (changeAmount > 0) { + App.game.wallet.addAmount(new Amount(changeAmount,currency),true); + } else if (changeAmount < 0) { + changeAmount = Math.abs(changeAmount); + if (changeAmount > App.game.wallet.currencies[currency]()) { + changeAmount = App.game.wallet.currencies[currency](); + if (changeAmount == 0) { + return; + } + } + App.game.wallet.loseAmount(new Amount(changeAmount,currency)); + } } function filterPkdx(){ - let lst = document.querySelectorAll(':scope #pkdx tbody tr'); - for (let i = 0; i < lst.length; i++) { - const tdb = lst[i]; - let display = true; - - if (document.getElementById('pkdxNameFilter').value !== ""){ - display = tdb.innerHTML.match(/.*<\/td>/g)[3].toLowerCase().includes(document.getElementById('pkdxNameFilter').value.toLowerCase()); - } - - if (display === true) { - switch (document.getElementById('pkdxRegionFilter').value) { - case 'all': - break; - default: - display = tdb.innerHTML.match(/.*<\/td>/g)[1].toLowerCase().includes(document.getElementById('pkdxRegionFilter').value); - break; - } - } - - if (display === true) { - switch (document.getElementById('pkdxShinyFilter').value) { - case 'uncaught': - display = tdb.innerHTML.includes('None.svg'); - break; - case 'caught': - display = tdb.innerHTML.includes('Pokeball.svg') || tdb.innerHTML.includes('Pokeball-shiny.svg'); - break; - case 'caught-not-shiny': - display = tdb.innerHTML.includes('Pokeball.svg'); - break; - case 'caught-shiny': - display = tdb.innerHTML.includes('Pokeball-shiny.svg'); - break; - default: - break; - } - } - - if (display === true) { - switch (document.getElementById('pkdxPKRSFilter').value) { - case '0': - display = tdb.innerHTML.includes('Infected.png'); - break; - case '2': - display = tdb.innerHTML.includes('Contagious.png'); - break; - case '3': - display = tdb.innerHTML.includes('Resistant.png'); - break; - default: - break; - } - } - - tdb.style.display = (display === true ? "" : "none"); - } + let lst = document.querySelectorAll(':scope #pkdx tbody tr'); + for (let i = 0; i < lst.length; i++) { + const tdb = lst[i]; + let display = true; + + if (document.getElementById('pkdxNameFilter').value !== ""){ + display = tdb.innerHTML.match(/.*<\/td>/g)[3].toLowerCase().includes(document.getElementById('pkdxNameFilter').value.toLowerCase()); + } + + if (display === true) { + switch (document.getElementById('pkdxRegionFilter').value) { + case 'all': + break; + default: + display = tdb.innerHTML.match(/.*<\/td>/g)[1].toLowerCase().includes(document.getElementById('pkdxRegionFilter').value); + break; + } + } + + if (display === true) { + switch (document.getElementById('pkdxShinyFilter').value) { + case 'uncaught': + display = tdb.innerHTML.includes('None.svg'); + break; + case 'caught': + display = tdb.innerHTML.includes('Pokeball.svg') || tdb.innerHTML.includes('Pokeball-shiny.svg'); + break; + case 'caught-not-shiny': + display = tdb.innerHTML.includes('Pokeball.svg'); + break; + case 'caught-shiny': + display = tdb.innerHTML.includes('Pokeball-shiny.svg'); + break; + default: + break; + } + } + + if (display === true) { + switch (document.getElementById('pkdxPKRSFilter').value) { + case '0': + display = tdb.innerHTML.includes('Infected.png'); + break; + case '2': + display = tdb.innerHTML.includes('Contagious.png'); + break; + case '3': + display = tdb.innerHTML.includes('Resistant.png'); + break; + default: + break; + } + } + + tdb.style.display = (display === true ? "" : "none"); + } } function filterQuestLine(){ - let lst = document.querySelectorAll(':scope #questlinelist tbody tr'); - for (let i = 0; i < lst.length; i++) { - const tdb = lst[i]; - let display = true; - - if (display === true) { - switch (document.getElementById('questLineFilter').value) { - case 'all': - break; - default: - display = tdb.innerHTML.toLowerCase().includes(document.getElementById('questLineFilter').value); - break; - } - } - - tdb.style.display = (display === true ? "" : "none"); - } + let lst = document.querySelectorAll(':scope #questlinelist tbody tr'); + for (let i = 0; i < lst.length; i++) { + const tdb = lst[i]; + let display = true; + + if (display === true) { + switch (document.getElementById('questLineFilter').value) { + case 'all': + break; + default: + display = tdb.innerHTML.toLowerCase().includes(document.getElementById('questLineFilter').value); + break; + } + } + + tdb.style.display = (display === true ? "" : "none"); + } } // eslint-disable-next-line no-unused-vars function loadPkdx(){ - let playerRegion = player.highestRegion(); - let pkdxBody = document.querySelector(':scope #pkdx tbody'); - pkdxBody.innerHTML = ''; - let toAdd = ""; - for (const pokemon of pokemonList) { - if ((pokemon.nativeRegion <= playerRegion && pokemon.nativeRegion > -1) || (pokemon.nativeRegion == -1 && playerRegion >= GameConstants.Region.alola) || pokemon.id == 0) { - let lpkm = App.game.party.getPokemon(pokemon.id); - let region = GameConstants.Region[pokemon.nativeRegion].charAt(0).toUpperCase() + GameConstants.Region[pokemon.nativeRegion].slice(1); - let hint = ""; - let getPokemonLocation = PokemonLocations.getPokemonLocations(pokemon.name, playerRegion); - let roadLocations = getPokemonLocation[0] - if (roadLocations) { - for (let i = 0; i <= playerRegion; i++) { - const reg = GameConstants.Region[i]; - let roads = "Route" - roadLocations[i]?.forEach((route) => { - roads += ` ${route.route},` - }); - if (roads !== "Route") - hint += `${hint !== "" ? `\n` : ""}${reg.charAt(0).toUpperCase() + reg.slice(1)}: ${roads.slice(0, -1)}`; - } - if (hint !== "") - hint = ` title="${hint}"`; - } - toAdd += ` - - ${pokemon.id} - ${region} - - ${pokemon.name} - - - YES') : '194, 46, 40);">NO'} - - `; - } - } - pkdxBody.innerHTML = toAdd; - filterPkdx(); - loadEventHandlers(); + let playerRegion = player.highestRegion(); + let pkdxBody = document.querySelector(':scope #pkdx tbody'); + pkdxBody.innerHTML = ''; + let toAdd = ""; + for (const pokemon of pokemonList) { + if ((pokemon.nativeRegion <= playerRegion && pokemon.nativeRegion > -1) || (pokemon.nativeRegion == -1 && playerRegion >= GameConstants.Region.alola) || pokemon.id == 0) { + let lpkm = App.game.party.getPokemon(pokemon.id); + let region = GameConstants.Region[pokemon.nativeRegion].charAt(0).toUpperCase() + GameConstants.Region[pokemon.nativeRegion].slice(1); + let hint = ""; + let getPokemonLocation = PokemonLocations.getPokemonLocations(pokemon.name, playerRegion); + let roadLocations = getPokemonLocation[0] + if (roadLocations) { + for (let i = 0; i <= playerRegion; i++) { + const reg = GameConstants.Region[i]; + let roads = "Route" + roadLocations[i]?.forEach((route) => { + roads += ` ${route.route},` + }); + if (roads !== "Route") + hint += `${hint !== "" ? `\n` : ""}${reg.charAt(0).toUpperCase() + reg.slice(1)}: ${roads.slice(0, -1)}`; + } + if (hint !== "") + hint = ` title="${hint}"`; + } + toAdd += ` + + ${pokemon.id} + ${region} + + ${pokemon.name} + + + YES') : '194, 46, 40);">NO'} + + `; + } + } + pkdxBody.innerHTML = toAdd; + filterPkdx(); + loadEventHandlers(); } function loadQuestLines() { - let qlBody = document.querySelector(':scope #questlinelist tbody'); - qlBody.innerHTML = ''; - let toAdd = ""; - - for (const ql of App.game.quests.questLines()) { - let state = QuestLineState[ql.state()] - state = state.charAt(0).toUpperCase() + state.slice(1) - - let stateColor; - switch (ql.state()) { - case 0: - stateColor = "244, 80, 80"; - break; - case 1: - stateColor = "99, 144, 240"; - break; - case 2: - stateColor = "122, 199, 76"; - break; - } - - toAdd += ` + let qlBody = document.querySelector(':scope #questlinelist tbody'); + qlBody.innerHTML = ''; + let toAdd = ""; + + for (const ql of App.game.quests.questLines()) { + let state = QuestLineState[ql.state()] + state = state.charAt(0).toUpperCase() + state.slice(1) + + let stateColor; + switch (ql.state()) { + case 0: + stateColor = "244, 80, 80"; + break; + case 1: + stateColor = "99, 144, 240"; + break; + case 2: + stateColor = "122, 199, 76"; + break; + } + + toAdd += ` ${ql.name} ${state} `; - } + } - // App.game.quests.questLines().filter(e => e.state() < 2).forEach(e => console.log(e.name, e.state())) + // App.game.quests.questLines().filter(e => e.state() < 2).forEach(e => console.log(e.name, e.state())) - qlBody.innerHTML = toAdd; - filterQuestLine(); - loadEventHandlers(); + qlBody.innerHTML = toAdd; + filterQuestLine(); + loadEventHandlers(); } function loadEventHandlers() { - - // currency - for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { - document.getElementById("currency_" + i).addEventListener("click", gainCurrency); - } - - // gems - for (let i = 0; i < Gems.nTypes; i++) { - document.getElementById("gems_" + i).addEventListener("click", function () { - App.game.gems.gainGems(parseInt(document.getElementById('inputAddGems').value || 0), parseInt(this.getAttribute("gem"))); - }); - } - - // pokeballs - for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { - document.getElementById("pokeballs_" + i).addEventListener("click", function () { - App.game.pokeballs.gainPokeballs(parseInt(this.getAttribute("pokeball")), parseInt(document.getElementById('inputAddPokeballs').value || 0), true); - }); - } - - // berries - for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { - document.getElementById("berries_" + i).addEventListener("click", function () { - App.game.farming.gainBerry(parseInt(this.getAttribute("berry")), parseInt(document.getElementById('inputAddBerries').value || 0), true); - }); - } - - // evolutionitems - for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { - document.getElementById("evolutionitems_" + i).addEventListener("click", function () { - player.gainItem(ItemList[this.getAttribute("item")].name, parseInt(document.getElementById('inputAddEvolutionItems').value || 0), true); - }); - } - - // vitamins - for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { - document.getElementById("vitamins_" + i).addEventListener("click", function () { - player.gainItem(ItemList[this.getAttribute("vitamin")].name, parseInt(document.getElementById('inputAddVitamins').value || 0), true); - }); - } - - // heldItems - HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { - document.getElementById("attackhelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().attack.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { - document.getElementById("typehelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().typeRestricted.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { - document.getElementById("evhelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().ev.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { - document.getElementById("exphelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().exp.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { - document.getElementById("otherhelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().other.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - - //pokedex events - document.getElementById("pokedex").children[1].addEventListener("click", loadPkdx); - document.getElementById("pkdxNameFilter").addEventListener("input", filterPkdx); - document.getElementById("pkdxRegionFilter").addEventListener("change", filterPkdx); - document.getElementById("pkdxShinyFilter").addEventListener("change", filterPkdx); - document.getElementById("pkdxPKRSFilter").addEventListener("change", filterPkdx); - for (const pokemon of pokemonList) { - let pkElement = document.getElementById("pkdx_" + pokemon.id.toString().replace('.','_')); - if (pkElement){ - pkElement.children[4].addEventListener("click", gainPk); - pkElement.children[5].addEventListener("click", gainPkrs); - } - } - //questline events - document.getElementById("questlines").children[1].addEventListener("click", loadQuestLines); - document.getElementById("questLineFilter").addEventListener("change", filterQuestLine); + // currency + for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { + document.getElementById("currency_" + i).addEventListener("click", gainCurrency); + } + + // gems + for (let i = 0; i < Gems.nTypes; i++) { + document.getElementById("gems_" + i).addEventListener("click", function () { + App.game.gems.gainGems(parseInt(document.getElementById('inputAddGems').value || 0), i); + }); + } + + // pokeballs + for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { + document.getElementById("pokeballs_" + i).addEventListener("click", function () { + App.game.pokeballs.gainPokeballs(i, parseInt(document.getElementById('inputAddPokeballs').value || 0), true); + }); + } + + // berries + for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { + document.getElementById("berries_" + i).addEventListener("click", function () { + App.game.farming.gainBerry(i, parseInt(document.getElementById('inputAddBerries').value || 0), true); + }); + } + + // evolutionitems + for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { + document.getElementById("evolutionitems_" + i).addEventListener("click", function () { + player.gainItem(ItemList[this.getAttribute("item")].name, parseInt(document.getElementById('inputAddEvolutionItems').value || 0), true); + }); + } + + // vitamins + for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { + document.getElementById("vitamins_" + i).addEventListener("click", function () { + player.gainItem(ItemList[this.getAttribute("vitamin")].name, parseInt(document.getElementById('inputAddVitamins').value || 0), true); + }); + } + + // heldItems + HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { + document.getElementById("attackhelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().attack.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { + document.getElementById("typehelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().typeRestricted.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { + document.getElementById("evhelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().ev.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { + document.getElementById("exphelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().exp.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { + document.getElementById("otherhelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().other.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + + // pokedex + document.getElementById("pokedex").children[1].addEventListener("click", loadPkdx); + document.getElementById("pkdxNameFilter").addEventListener("input", filterPkdx); + document.getElementById("pkdxRegionFilter").addEventListener("change", filterPkdx); + document.getElementById("pkdxShinyFilter").addEventListener("change", filterPkdx); + document.getElementById("pkdxPKRSFilter").addEventListener("change", filterPkdx); + for (const pokemon of pokemonList) { + let pkElement = document.getElementById("pkdx_" + pokemon.id.toString().replace('.','_')); + if (pkElement){ + pkElement.children[4].addEventListener("click", gainPk); + pkElement.children[5].addEventListener("click", gainPkrs); + } + } + + // questline + document.getElementById("questlines").children[1].addEventListener("click", loadQuestLines); + document.getElementById("questLineFilter").addEventListener("change", filterQuestLine); } function initSaveEditor() { - // Add menu item - let eventLi = document.createElement('li'); - eventLi.innerHTML = `Debug Cheats` - profileDrop.before(eventLi); - - // Add popup - let eventMod = document.createElement('div'); - eventMod.setAttribute("class", "modal noselect fade show"); - eventMod.setAttribute("id", "saveEditorModal"); - eventMod.setAttribute("tabindex", "-1"); - eventMod.setAttribute("aria-labelledby", "saveEditorModal"); - eventMod.setAttribute("aria-modal", "true"); - eventMod.setAttribute("role", "dialog"); - - eventMod.innerHTML = ` - - `; - - profileModal.before(eventMod); - - let modalBody = document.querySelector('[id=saveEditorModal] div div [class=modal-body]'); - - // currency - for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { - const itm = GameConstants.Currency[i]; - const itmPretty = itm.charAt(0).toUpperCase() + itm.replace(/[A-Z]/g, ' $&').trim().slice(1); - modalBody.querySelector('#currency').innerHTML += ` -
- -
${itmPretty}
-
- `; - } - - // gems - for (let i = 0; i < Gems.nTypes; i++) { - const itm = PokemonType[i]; - modalBody.querySelector('#gems').innerHTML += ` -
- -
${itm}
-
- `; - } - - // pokeballs - for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { - const itm = GameConstants.Pokeball[i]; - modalBody.querySelector('#pokeballs').innerHTML += ` -
- -
${itm}
-
- `; - } - - // berries - for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { - const itm = BerryType[i]; - modalBody.querySelector('#berries').innerHTML += ` -
- -
${itm}
-
- `; - } - - // evolutionitems - for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { - const itm = GameConstants.StoneType[i]; - const itmPretty = itm.replaceAll('_', ' '); - modalBody.querySelector('#evolutionitems').innerHTML += ` -
- -
${itmPretty}
-
- `; - } - - // vitamins - for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { - const itm = GameConstants.VitaminType[i]; - modalBody.querySelector('#vitamins').innerHTML += ` -
- -
${itm}
-
- `; - } - - // heldItems - HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - - // pokedex - const pkdxRegFilt = modalBody.querySelector('#pkdxRegionFilter'); - for (let i = 0; i <= player.highestRegion(); i++) { - const reg = GameConstants.Region[i] - pkdxRegFilt.innerHTML += ``; - } - pkdxRegFilt.innerHTML += ''; - - - loadEventHandlers(); + // Add menu item + let eventLi = document.createElement('li'); + eventLi.innerHTML = `Debug Cheats` + profileDrop.before(eventLi); + + // Add popup + let eventMod = document.createElement('div'); + eventMod.setAttribute("class", "modal noselect fade show"); + eventMod.setAttribute("id", "saveEditorModal"); + eventMod.setAttribute("tabindex", "-1"); + eventMod.setAttribute("aria-labelledby", "saveEditorModal"); + eventMod.setAttribute("aria-modal", "true"); + eventMod.setAttribute("role", "dialog"); + + eventMod.innerHTML = ` + + `; + + profileModal.before(eventMod); + + let modalBody = document.querySelector('[id=saveEditorModal] div div [class=modal-body]'); + + // currency + for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { + const itm = GameConstants.Currency[i]; + const itmPretty = itm.charAt(0).toUpperCase() + itm.replace(/[A-Z]/g, ' $&').trim().slice(1); + modalBody.querySelector('#currency').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + } + + // gems + for (let i = 0; i < Gems.nTypes; i++) { + const itm = PokemonType[i]; + modalBody.querySelector('#gems').innerHTML += ` +
+ +
${itm}
+
+ `; + } + + // pokeballs + for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { + const itm = GameConstants.Pokeball[i]; + modalBody.querySelector('#pokeballs').innerHTML += ` +
+ +
${itm}
+
+ `; + } + + // berries + for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { + const itm = BerryType[i]; + modalBody.querySelector('#berries').innerHTML += ` +
+ +
${itm}
+
+ `; + } + + // evolutionitems + for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { + const itm = GameConstants.StoneType[i]; + const itmPretty = itm.replaceAll('_', ' '); + modalBody.querySelector('#evolutionitems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + } + + // vitamins + for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { + const itm = GameConstants.VitaminType[i]; + modalBody.querySelector('#vitamins').innerHTML += ` +
+ +
${itm}
+
+ `; + } + + // heldItems + HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + + // pokedex + const pkdxRegFilt = modalBody.querySelector('#pkdxRegionFilter'); + for (let i = 0; i <= player.highestRegion(); i++) { + const reg = GameConstants.Region[i] + pkdxRegFilt.innerHTML += ``; + } + pkdxRegFilt.innerHTML += ''; + + + loadEventHandlers(); } /* WIP, sevii helper var lst = pokemonList.filter((p) => p.name.includes('Pinkan') - || p.name.includes('Valencian') - || p.name === 'Crystal Onix' - || p.name === 'Ash\'s Butterfree' - || p.name === 'Pink Butterfree'); + || p.name.includes('Valencian') + || p.name === 'Crystal Onix' + || p.name === 'Ash\'s Butterfree' + || p.name === 'Pink Butterfree'); var caught = App.game.party.caughtPokemon - .filter((p) => p.name.includes('Pinkan') - || p.name.includes('Valencian') - || p.name === 'Crystal Onix' - || p.name === 'Ash\'s Butterfree' - || p.name === 'Pink Butterfree'); + .filter((p) => p.name.includes('Pinkan') + || p.name.includes('Valencian') + || p.name === 'Crystal Onix' + || p.name === 'Ash\'s Butterfree' + || p.name === 'Pink Butterfree'); var caughtNames = caught.map(e => e.name); var missing = lst.filter(e => !caughtNames.includes(e.name)); @@ -618,71 +618,71 @@ console.log(missing); */ function loadEpheniaScript(scriptName, initFunction, priorityFunction) { - function reportScriptError(scriptName, error) { - console.error(`Error while initializing '${scriptName}' userscript:\n${error}`); - Notifier.notify({ - type: NotificationConstants.NotificationOption.warning, - title: scriptName, - message: `The '${scriptName}' userscript crashed while loading. Check for updates or disable the script, then restart the game.\n\nReport script issues to the script developer, not to the Pokéclicker team.`, - timeout: GameConstants.DAY, - }); - } - const windowObject = !App.isUsingClient ? unsafeWindow : window; - // Inject handlers if they don't exist yet - if (windowObject.epheniaScriptInitializers === undefined) { - windowObject.epheniaScriptInitializers = {}; - const oldInit = Preload.hideSplashScreen; - var hasInitialized = false; - - // Initializes scripts once enough of the game has loaded - Preload.hideSplashScreen = function (...args) { - var result = oldInit.apply(this, args); - if (App.game && !hasInitialized) { - // Initialize all attached userscripts - Object.entries(windowObject.epheniaScriptInitializers).forEach(([scriptName, initFunction]) => { - try { - initFunction(); - } catch (e) { - reportScriptError(scriptName, e); - } - }); - hasInitialized = true; - } - return result; - } - } - - // Prevent issues with duplicate script names - if (windowObject.epheniaScriptInitializers[scriptName] !== undefined) { - console.warn(`Duplicate '${scriptName}' userscripts found!`); - Notifier.notify({ - type: NotificationConstants.NotificationOption.warning, - title: scriptName, - message: `Duplicate '${scriptName}' userscripts detected. This could cause unpredictable behavior and is not recommended.`, - timeout: GameConstants.DAY, - }); - let number = 2; - while (windowObject.epheniaScriptInitializers[`${scriptName} ${number}`] !== undefined) { - number++; - } - scriptName = `${scriptName} ${number}`; - } - // Add initializer for this particular script - windowObject.epheniaScriptInitializers[scriptName] = initFunction; - // Run any functions that need to execute before the game starts - if (priorityFunction) { - $(document).ready(() => { - try { - priorityFunction(); - } catch (e) { - reportScriptError(scriptName, e); - // Remove main initialization function - windowObject.epheniaScriptInitializers[scriptName] = () => null; - } - }); - } + function reportScriptError(scriptName, error) { + console.error(`Error while initializing '${scriptName}' userscript:\n${error}`); + Notifier.notify({ + type: NotificationConstants.NotificationOption.warning, + title: scriptName, + message: `The '${scriptName}' userscript crashed while loading. Check for updates or disable the script, then restart the game.\n\nReport script issues to the script developer, not to the Pokéclicker team.`, + timeout: GameConstants.DAY, + }); + } + const windowObject = !App.isUsingClient ? unsafeWindow : window; + // Inject handlers if they don't exist yet + if (windowObject.epheniaScriptInitializers === undefined) { + windowObject.epheniaScriptInitializers = {}; + const oldInit = Preload.hideSplashScreen; + var hasInitialized = false; + + // Initializes scripts once enough of the game has loaded + Preload.hideSplashScreen = function (...args) { + var result = oldInit.apply(this, args); + if (App.game && !hasInitialized) { + // Initialize all attached userscripts + Object.entries(windowObject.epheniaScriptInitializers).forEach(([scriptName, initFunction]) => { + try { + initFunction(); + } catch (e) { + reportScriptError(scriptName, e); + } + }); + hasInitialized = true; + } + return result; + } + } + + // Prevent issues with duplicate script names + if (windowObject.epheniaScriptInitializers[scriptName] !== undefined) { + console.warn(`Duplicate '${scriptName}' userscripts found!`); + Notifier.notify({ + type: NotificationConstants.NotificationOption.warning, + title: scriptName, + message: `Duplicate '${scriptName}' userscripts detected. This could cause unpredictable behavior and is not recommended.`, + timeout: GameConstants.DAY, + }); + let number = 2; + while (windowObject.epheniaScriptInitializers[`${scriptName} ${number}`] !== undefined) { + number++; + } + scriptName = `${scriptName} ${number}`; + } + // Add initializer for this particular script + windowObject.epheniaScriptInitializers[scriptName] = initFunction; + // Run any functions that need to execute before the game starts + if (priorityFunction) { + $(document).ready(() => { + try { + priorityFunction(); + } catch (e) { + reportScriptError(scriptName, e); + // Remove main initialization function + windowObject.epheniaScriptInitializers[scriptName] = () => null; + } + }); + } } if (!App.isUsingClient || localStorage.getItem('debugcheatstools') === 'true') { - loadEpheniaScript('debugcheatstools', initSaveEditor); + loadEpheniaScript('debugcheatstools', initSaveEditor); } From fe12e37622c3b154a5b2c7549ddbf873fbf84d2b Mon Sep 17 00:00:00 2001 From: iamc24 <42425100+iamc24@users.noreply.github.com> Date: Sun, 27 Jul 2025 13:49:30 -0700 Subject: [PATCH 09/14] Update debugcheatstools.user.js fix indents --- custom/debugcheatstools.user.js | 1224 +++++++++++++++---------------- 1 file changed, 612 insertions(+), 612 deletions(-) diff --git a/custom/debugcheatstools.user.js b/custom/debugcheatstools.user.js index 7978af6..6ffab17 100644 --- a/custom/debugcheatstools.user.js +++ b/custom/debugcheatstools.user.js @@ -24,592 +24,592 @@ const profileDrop = document.getElementById('startMenu').querySelectorAll('ul li const profileModal = document.getElementById('profileModal'); function getPokerusImgSrc(id, pkm){ - let lpkm = pkm || App.game.party.getPokemon(id); - return lpkm?.pokerus || 0 > 0 ? (lpkm.pokerus === 3 ? "assets/images/breeding/pokerus/Resistant.png" : "assets/images/breeding/pokerus/Contagious.png") : "assets/images/breeding/pokerus/Infected.png"; + let lpkm = pkm || App.game.party.getPokemon(id); + return lpkm?.pokerus || 0 > 0 ? (lpkm.pokerus === 3 ? "assets/images/breeding/pokerus/Resistant.png" : "assets/images/breeding/pokerus/Contagious.png") : "assets/images/breeding/pokerus/Infected.png"; } function getPokeballImgSrc(id, pkm){ - let lpkm = pkm || App.game.party.getPokemon(id); - return lpkm ? ((lpkm?.shiny === true) ? "assets/images/pokeball/Pokeball-shiny.svg" : "assets/images/pokeball/Pokeball.svg") : "assets/images/pokeball/None.svg"; + let lpkm = pkm || App.game.party.getPokemon(id); + return lpkm ? ((lpkm?.shiny === true) ? "assets/images/pokeball/Pokeball-shiny.svg" : "assets/images/pokeball/Pokeball.svg") : "assets/images/pokeball/None.svg"; } // eslint-disable-next-line no-unused-vars function gainPk(){ - let id = parseFloat(this.parentElement.children[0].innerHTML); - let lpkm = App.game.party.getPokemon(id); - if (!lpkm) - App.game.party.gainPokemonById(id) - else if (!(lpkm?.shiny === true)) - App.game.party.gainPokemonById(id, true); - document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[1].src = getPokeballImgSrc(id, lpkm); - filterPkdx(); - loadEventHandlers(); + let id = parseFloat(this.parentElement.children[0].innerHTML); + let lpkm = App.game.party.getPokemon(id); + if (!lpkm) + App.game.party.gainPokemonById(id) + else if (!(lpkm?.shiny === true)) + App.game.party.gainPokemonById(id, true); + document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[1].src = getPokeballImgSrc(id, lpkm); + filterPkdx(); + loadEventHandlers(); } // eslint-disable-next-line no-unused-vars function gainPkrs(){ - let id = parseFloat(this.parentElement.children[0].innerHTML); - let lpkm = App.game.party.getPokemon(id); - if (!lpkm) return; - lpkm.effortPoints = ((lpkm.pokerus < 2) ? 1 : 50) * 1000; // strange - lpkm.pokerus = (lpkm.pokerus < 2) ? 2 : 3; - document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[2].src = getPokerusImgSrc(id, lpkm); - filterPkdx(); - loadEventHandlers(); + let id = parseFloat(this.parentElement.children[0].innerHTML); + let lpkm = App.game.party.getPokemon(id); + if (!lpkm) return; + lpkm.effortPoints = ((lpkm.pokerus < 2) ? 1 : 50) * 1000; // strange + lpkm.pokerus = (lpkm.pokerus < 2) ? 2 : 3; + document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[2].src = getPokerusImgSrc(id, lpkm); + filterPkdx(); + loadEventHandlers(); } function gainCurrency() { - let currency = parseInt(this.getAttribute("currency")); - let changeAmount = parseInt(document.getElementById("inputAddCurrency").value || 0); - if (changeAmount > 0) { - App.game.wallet.addAmount(new Amount(changeAmount,currency),true); - } else if (changeAmount < 0) { - changeAmount = Math.abs(changeAmount); - if (changeAmount > App.game.wallet.currencies[currency]()) { - changeAmount = App.game.wallet.currencies[currency](); - if (changeAmount == 0) { - return; - } - } - App.game.wallet.loseAmount(new Amount(changeAmount,currency)); - } + let currency = parseInt(this.getAttribute("currency")); + let changeAmount = parseInt(document.getElementById("inputAddCurrency").value || 0); + if (changeAmount > 0) { + App.game.wallet.addAmount(new Amount(changeAmount,currency),true); + } else if (changeAmount < 0) { + changeAmount = Math.abs(changeAmount); + if (changeAmount > App.game.wallet.currencies[currency]()) { + changeAmount = App.game.wallet.currencies[currency](); + if (changeAmount == 0) { + return; + } + } + App.game.wallet.loseAmount(new Amount(changeAmount,currency)); + } } function filterPkdx(){ - let lst = document.querySelectorAll(':scope #pkdx tbody tr'); - for (let i = 0; i < lst.length; i++) { - const tdb = lst[i]; - let display = true; - - if (document.getElementById('pkdxNameFilter').value !== ""){ - display = tdb.innerHTML.match(/.*<\/td>/g)[3].toLowerCase().includes(document.getElementById('pkdxNameFilter').value.toLowerCase()); - } - - if (display === true) { - switch (document.getElementById('pkdxRegionFilter').value) { - case 'all': - break; - default: - display = tdb.innerHTML.match(/.*<\/td>/g)[1].toLowerCase().includes(document.getElementById('pkdxRegionFilter').value); - break; - } - } - - if (display === true) { - switch (document.getElementById('pkdxShinyFilter').value) { - case 'uncaught': - display = tdb.innerHTML.includes('None.svg'); - break; - case 'caught': - display = tdb.innerHTML.includes('Pokeball.svg') || tdb.innerHTML.includes('Pokeball-shiny.svg'); - break; - case 'caught-not-shiny': - display = tdb.innerHTML.includes('Pokeball.svg'); - break; - case 'caught-shiny': - display = tdb.innerHTML.includes('Pokeball-shiny.svg'); - break; - default: - break; - } - } - - if (display === true) { - switch (document.getElementById('pkdxPKRSFilter').value) { - case '0': - display = tdb.innerHTML.includes('Infected.png'); - break; - case '2': - display = tdb.innerHTML.includes('Contagious.png'); - break; - case '3': - display = tdb.innerHTML.includes('Resistant.png'); - break; - default: - break; - } - } - - tdb.style.display = (display === true ? "" : "none"); - } + let lst = document.querySelectorAll(':scope #pkdx tbody tr'); + for (let i = 0; i < lst.length; i++) { + const tdb = lst[i]; + let display = true; + + if (document.getElementById('pkdxNameFilter').value !== ""){ + display = tdb.innerHTML.match(/.*<\/td>/g)[3].toLowerCase().includes(document.getElementById('pkdxNameFilter').value.toLowerCase()); + } + + if (display === true) { + switch (document.getElementById('pkdxRegionFilter').value) { + case 'all': + break; + default: + display = tdb.innerHTML.match(/.*<\/td>/g)[1].toLowerCase().includes(document.getElementById('pkdxRegionFilter').value); + break; + } + } + + if (display === true) { + switch (document.getElementById('pkdxShinyFilter').value) { + case 'uncaught': + display = tdb.innerHTML.includes('None.svg'); + break; + case 'caught': + display = tdb.innerHTML.includes('Pokeball.svg') || tdb.innerHTML.includes('Pokeball-shiny.svg'); + break; + case 'caught-not-shiny': + display = tdb.innerHTML.includes('Pokeball.svg'); + break; + case 'caught-shiny': + display = tdb.innerHTML.includes('Pokeball-shiny.svg'); + break; + default: + break; + } + } + + if (display === true) { + switch (document.getElementById('pkdxPKRSFilter').value) { + case '0': + display = tdb.innerHTML.includes('Infected.png'); + break; + case '2': + display = tdb.innerHTML.includes('Contagious.png'); + break; + case '3': + display = tdb.innerHTML.includes('Resistant.png'); + break; + default: + break; + } + } + + tdb.style.display = (display === true ? "" : "none"); + } } function filterQuestLine(){ - let lst = document.querySelectorAll(':scope #questlinelist tbody tr'); - for (let i = 0; i < lst.length; i++) { - const tdb = lst[i]; - let display = true; - - if (display === true) { - switch (document.getElementById('questLineFilter').value) { - case 'all': - break; - default: - display = tdb.innerHTML.toLowerCase().includes(document.getElementById('questLineFilter').value); - break; - } - } - - tdb.style.display = (display === true ? "" : "none"); - } + let lst = document.querySelectorAll(':scope #questlinelist tbody tr'); + for (let i = 0; i < lst.length; i++) { + const tdb = lst[i]; + let display = true; + + if (display === true) { + switch (document.getElementById('questLineFilter').value) { + case 'all': + break; + default: + display = tdb.innerHTML.toLowerCase().includes(document.getElementById('questLineFilter').value); + break; + } + } + + tdb.style.display = (display === true ? "" : "none"); + } } // eslint-disable-next-line no-unused-vars function loadPkdx(){ - let playerRegion = player.highestRegion(); - let pkdxBody = document.querySelector(':scope #pkdx tbody'); - pkdxBody.innerHTML = ''; - let toAdd = ""; - for (const pokemon of pokemonList) { - if ((pokemon.nativeRegion <= playerRegion && pokemon.nativeRegion > -1) || (pokemon.nativeRegion == -1 && playerRegion >= GameConstants.Region.alola) || pokemon.id == 0) { - let lpkm = App.game.party.getPokemon(pokemon.id); - let region = GameConstants.Region[pokemon.nativeRegion].charAt(0).toUpperCase() + GameConstants.Region[pokemon.nativeRegion].slice(1); - let hint = ""; - let getPokemonLocation = PokemonLocations.getPokemonLocations(pokemon.name, playerRegion); - let roadLocations = getPokemonLocation[0] - if (roadLocations) { - for (let i = 0; i <= playerRegion; i++) { - const reg = GameConstants.Region[i]; - let roads = "Route" - roadLocations[i]?.forEach((route) => { - roads += ` ${route.route},` - }); - if (roads !== "Route") - hint += `${hint !== "" ? `\n` : ""}${reg.charAt(0).toUpperCase() + reg.slice(1)}: ${roads.slice(0, -1)}`; - } - if (hint !== "") - hint = ` title="${hint}"`; - } - toAdd += ` - - ${pokemon.id} - ${region} - - ${pokemon.name} - - - YES') : '194, 46, 40);">NO'} - - `; - } - } - pkdxBody.innerHTML = toAdd; - filterPkdx(); - loadEventHandlers(); + let playerRegion = player.highestRegion(); + let pkdxBody = document.querySelector(':scope #pkdx tbody'); + pkdxBody.innerHTML = ''; + let toAdd = ""; + for (const pokemon of pokemonList) { + if ((pokemon.nativeRegion <= playerRegion && pokemon.nativeRegion > -1) || (pokemon.nativeRegion == -1 && playerRegion >= GameConstants.Region.alola) || pokemon.id == 0) { + let lpkm = App.game.party.getPokemon(pokemon.id); + let region = GameConstants.Region[pokemon.nativeRegion].charAt(0).toUpperCase() + GameConstants.Region[pokemon.nativeRegion].slice(1); + let hint = ""; + let getPokemonLocation = PokemonLocations.getPokemonLocations(pokemon.name, playerRegion); + let roadLocations = getPokemonLocation[0] + if (roadLocations) { + for (let i = 0; i <= playerRegion; i++) { + const reg = GameConstants.Region[i]; + let roads = "Route" + roadLocations[i]?.forEach((route) => { + roads += ` ${route.route},` + }); + if (roads !== "Route") + hint += `${hint !== "" ? `\n` : ""}${reg.charAt(0).toUpperCase() + reg.slice(1)}: ${roads.slice(0, -1)}`; + } + if (hint !== "") + hint = ` title="${hint}"`; + } + toAdd += ` + + ${pokemon.id} + ${region} + + ${pokemon.name} + + + YES') : '194, 46, 40);">NO'} + + `; + } + } + pkdxBody.innerHTML = toAdd; + filterPkdx(); + loadEventHandlers(); } function loadQuestLines() { - let qlBody = document.querySelector(':scope #questlinelist tbody'); - qlBody.innerHTML = ''; - let toAdd = ""; - - for (const ql of App.game.quests.questLines()) { - let state = QuestLineState[ql.state()] - state = state.charAt(0).toUpperCase() + state.slice(1) - - let stateColor; - switch (ql.state()) { - case 0: - stateColor = "244, 80, 80"; - break; - case 1: - stateColor = "99, 144, 240"; - break; - case 2: - stateColor = "122, 199, 76"; - break; - } - - toAdd += ` - - ${ql.name} - ${state} - - `; - } - - // App.game.quests.questLines().filter(e => e.state() < 2).forEach(e => console.log(e.name, e.state())) - - qlBody.innerHTML = toAdd; - filterQuestLine(); - loadEventHandlers(); + let qlBody = document.querySelector(':scope #questlinelist tbody'); + qlBody.innerHTML = ''; + let toAdd = ""; + + for (const ql of App.game.quests.questLines()) { + let state = QuestLineState[ql.state()] + state = state.charAt(0).toUpperCase() + state.slice(1) + + let stateColor; + switch (ql.state()) { + case 0: + stateColor = "244, 80, 80"; + break; + case 1: + stateColor = "99, 144, 240"; + break; + case 2: + stateColor = "122, 199, 76"; + break; + } + + toAdd += ` + + ${ql.name} + ${state} + + `; + } + + // App.game.quests.questLines().filter(e => e.state() < 2).forEach(e => console.log(e.name, e.state())) + + qlBody.innerHTML = toAdd; + filterQuestLine(); + loadEventHandlers(); } function loadEventHandlers() { - // currency - for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { - document.getElementById("currency_" + i).addEventListener("click", gainCurrency); - } - - // gems - for (let i = 0; i < Gems.nTypes; i++) { - document.getElementById("gems_" + i).addEventListener("click", function () { - App.game.gems.gainGems(parseInt(document.getElementById('inputAddGems').value || 0), i); - }); - } - - // pokeballs - for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { - document.getElementById("pokeballs_" + i).addEventListener("click", function () { - App.game.pokeballs.gainPokeballs(i, parseInt(document.getElementById('inputAddPokeballs').value || 0), true); - }); - } - - // berries - for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { - document.getElementById("berries_" + i).addEventListener("click", function () { - App.game.farming.gainBerry(i, parseInt(document.getElementById('inputAddBerries').value || 0), true); - }); - } - - // evolutionitems - for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { - document.getElementById("evolutionitems_" + i).addEventListener("click", function () { - player.gainItem(ItemList[this.getAttribute("item")].name, parseInt(document.getElementById('inputAddEvolutionItems').value || 0), true); - }); - } - - // vitamins - for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { - document.getElementById("vitamins_" + i).addEventListener("click", function () { - player.gainItem(ItemList[this.getAttribute("vitamin")].name, parseInt(document.getElementById('inputAddVitamins').value || 0), true); - }); - } - - // heldItems - HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { - document.getElementById("attackhelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().attack.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { - document.getElementById("typehelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().typeRestricted.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { - document.getElementById("evhelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().ev.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { - document.getElementById("exphelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().exp.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { - document.getElementById("otherhelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().other.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - - // pokedex - document.getElementById("pokedex").children[1].addEventListener("click", loadPkdx); - document.getElementById("pkdxNameFilter").addEventListener("input", filterPkdx); - document.getElementById("pkdxRegionFilter").addEventListener("change", filterPkdx); - document.getElementById("pkdxShinyFilter").addEventListener("change", filterPkdx); - document.getElementById("pkdxPKRSFilter").addEventListener("change", filterPkdx); - for (const pokemon of pokemonList) { - let pkElement = document.getElementById("pkdx_" + pokemon.id.toString().replace('.','_')); - if (pkElement){ - pkElement.children[4].addEventListener("click", gainPk); - pkElement.children[5].addEventListener("click", gainPkrs); - } - } - - // questline - document.getElementById("questlines").children[1].addEventListener("click", loadQuestLines); - document.getElementById("questLineFilter").addEventListener("change", filterQuestLine); + // currency + for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { + document.getElementById("currency_" + i).addEventListener("click", gainCurrency); + } + + // gems + for (let i = 0; i < Gems.nTypes; i++) { + document.getElementById("gems_" + i).addEventListener("click", function () { + App.game.gems.gainGems(parseInt(document.getElementById('inputAddGems').value || 0), i); + }); + } + + // pokeballs + for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { + document.getElementById("pokeballs_" + i).addEventListener("click", function () { + App.game.pokeballs.gainPokeballs(i, parseInt(document.getElementById('inputAddPokeballs').value || 0), true); + }); + } + + // berries + for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { + document.getElementById("berries_" + i).addEventListener("click", function () { + App.game.farming.gainBerry(i, parseInt(document.getElementById('inputAddBerries').value || 0), true); + }); + } + + // evolutionitems + for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { + document.getElementById("evolutionitems_" + i).addEventListener("click", function () { + player.gainItem(ItemList[this.getAttribute("item")].name, parseInt(document.getElementById('inputAddEvolutionItems').value || 0), true); + }); + } + + // vitamins + for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { + document.getElementById("vitamins_" + i).addEventListener("click", function () { + player.gainItem(ItemList[this.getAttribute("vitamin")].name, parseInt(document.getElementById('inputAddVitamins').value || 0), true); + }); + } + + // heldItems + HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { + document.getElementById("attackhelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().attack.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { + document.getElementById("typehelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().typeRestricted.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { + document.getElementById("evhelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().ev.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { + document.getElementById("exphelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().exp.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { + document.getElementById("otherhelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().other.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + + // pokedex + document.getElementById("pokedex").children[1].addEventListener("click", loadPkdx); + document.getElementById("pkdxNameFilter").addEventListener("input", filterPkdx); + document.getElementById("pkdxRegionFilter").addEventListener("change", filterPkdx); + document.getElementById("pkdxShinyFilter").addEventListener("change", filterPkdx); + document.getElementById("pkdxPKRSFilter").addEventListener("change", filterPkdx); + for (const pokemon of pokemonList) { + let pkElement = document.getElementById("pkdx_" + pokemon.id.toString().replace('.','_')); + if (pkElement){ + pkElement.children[4].addEventListener("click", gainPk); + pkElement.children[5].addEventListener("click", gainPkrs); + } + } + + // questline + document.getElementById("questlines").children[1].addEventListener("click", loadQuestLines); + document.getElementById("questLineFilter").addEventListener("change", filterQuestLine); } function initSaveEditor() { - // Add menu item - let eventLi = document.createElement('li'); - eventLi.innerHTML = `Debug Cheats` - profileDrop.before(eventLi); - - // Add popup - let eventMod = document.createElement('div'); - eventMod.setAttribute("class", "modal noselect fade show"); - eventMod.setAttribute("id", "saveEditorModal"); - eventMod.setAttribute("tabindex", "-1"); - eventMod.setAttribute("aria-labelledby", "saveEditorModal"); - eventMod.setAttribute("aria-modal", "true"); - eventMod.setAttribute("role", "dialog"); - - eventMod.innerHTML = ` - - `; - - profileModal.before(eventMod); - - let modalBody = document.querySelector('[id=saveEditorModal] div div [class=modal-body]'); - - // currency - for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { - const itm = GameConstants.Currency[i]; - const itmPretty = itm.charAt(0).toUpperCase() + itm.replace(/[A-Z]/g, ' $&').trim().slice(1); - modalBody.querySelector('#currency').innerHTML += ` -
- -
${itmPretty}
-
- `; - } - - // gems - for (let i = 0; i < Gems.nTypes; i++) { - const itm = PokemonType[i]; - modalBody.querySelector('#gems').innerHTML += ` -
- -
${itm}
-
- `; - } - - // pokeballs - for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { - const itm = GameConstants.Pokeball[i]; - modalBody.querySelector('#pokeballs').innerHTML += ` -
- -
${itm}
-
- `; - } - - // berries - for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { - const itm = BerryType[i]; - modalBody.querySelector('#berries').innerHTML += ` -
- -
${itm}
-
- `; - } - - // evolutionitems - for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { - const itm = GameConstants.StoneType[i]; - const itmPretty = itm.replaceAll('_', ' '); - modalBody.querySelector('#evolutionitems').innerHTML += ` -
- -
${itmPretty}
-
- `; - } - - // vitamins - for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { - const itm = GameConstants.VitaminType[i]; - modalBody.querySelector('#vitamins').innerHTML += ` -
- -
${itm}
-
- `; - } - - // heldItems - HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - - // pokedex - const pkdxRegFilt = modalBody.querySelector('#pkdxRegionFilter'); - for (let i = 0; i <= player.highestRegion(); i++) { - const reg = GameConstants.Region[i] - pkdxRegFilt.innerHTML += ``; - } - pkdxRegFilt.innerHTML += ''; - - - loadEventHandlers(); + // Add menu item + let eventLi = document.createElement('li'); + eventLi.innerHTML = `Debug Cheats` + profileDrop.before(eventLi); + + // Add popup + let eventMod = document.createElement('div'); + eventMod.setAttribute("class", "modal noselect fade show"); + eventMod.setAttribute("id", "saveEditorModal"); + eventMod.setAttribute("tabindex", "-1"); + eventMod.setAttribute("aria-labelledby", "saveEditorModal"); + eventMod.setAttribute("aria-modal", "true"); + eventMod.setAttribute("role", "dialog"); + + eventMod.innerHTML = ` + + `; + + profileModal.before(eventMod); + + let modalBody = document.querySelector('[id=saveEditorModal] div div [class=modal-body]'); + + // currency + for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { + const itm = GameConstants.Currency[i]; + const itmPretty = itm.charAt(0).toUpperCase() + itm.replace(/[A-Z]/g, ' $&').trim().slice(1); + modalBody.querySelector('#currency').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + } + + // gems + for (let i = 0; i < Gems.nTypes; i++) { + const itm = PokemonType[i]; + modalBody.querySelector('#gems').innerHTML += ` +
+ +
${itm}
+
+ `; + } + + // pokeballs + for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { + const itm = GameConstants.Pokeball[i]; + modalBody.querySelector('#pokeballs').innerHTML += ` +
+ +
${itm}
+
+ `; + } + + // berries + for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { + const itm = BerryType[i]; + modalBody.querySelector('#berries').innerHTML += ` +
+ +
${itm}
+
+ `; + } + + // evolutionitems + for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { + const itm = GameConstants.StoneType[i]; + const itmPretty = itm.replaceAll('_', ' '); + modalBody.querySelector('#evolutionitems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + } + + // vitamins + for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { + const itm = GameConstants.VitaminType[i]; + modalBody.querySelector('#vitamins').innerHTML += ` +
+ +
${itm}
+
+ `; + } + + // heldItems + HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + + // pokedex + const pkdxRegFilt = modalBody.querySelector('#pkdxRegionFilter'); + for (let i = 0; i <= player.highestRegion(); i++) { + const reg = GameConstants.Region[i] + pkdxRegFilt.innerHTML += ``; + } + pkdxRegFilt.innerHTML += ''; + + + loadEventHandlers(); } /* WIP, sevii helper var lst = pokemonList.filter((p) => p.name.includes('Pinkan') - || p.name.includes('Valencian') - || p.name === 'Crystal Onix' - || p.name === 'Ash\'s Butterfree' - || p.name === 'Pink Butterfree'); + || p.name.includes('Valencian') + || p.name === 'Crystal Onix' + || p.name === 'Ash\'s Butterfree' + || p.name === 'Pink Butterfree'); var caught = App.game.party.caughtPokemon - .filter((p) => p.name.includes('Pinkan') - || p.name.includes('Valencian') - || p.name === 'Crystal Onix' - || p.name === 'Ash\'s Butterfree' - || p.name === 'Pink Butterfree'); + .filter((p) => p.name.includes('Pinkan') + || p.name.includes('Valencian') + || p.name === 'Crystal Onix' + || p.name === 'Ash\'s Butterfree' + || p.name === 'Pink Butterfree'); var caughtNames = caught.map(e => e.name); var missing = lst.filter(e => !caughtNames.includes(e.name)); @@ -618,71 +618,71 @@ console.log(missing); */ function loadEpheniaScript(scriptName, initFunction, priorityFunction) { - function reportScriptError(scriptName, error) { - console.error(`Error while initializing '${scriptName}' userscript:\n${error}`); - Notifier.notify({ - type: NotificationConstants.NotificationOption.warning, - title: scriptName, - message: `The '${scriptName}' userscript crashed while loading. Check for updates or disable the script, then restart the game.\n\nReport script issues to the script developer, not to the Pokéclicker team.`, - timeout: GameConstants.DAY, - }); - } - const windowObject = !App.isUsingClient ? unsafeWindow : window; - // Inject handlers if they don't exist yet - if (windowObject.epheniaScriptInitializers === undefined) { - windowObject.epheniaScriptInitializers = {}; - const oldInit = Preload.hideSplashScreen; - var hasInitialized = false; - - // Initializes scripts once enough of the game has loaded - Preload.hideSplashScreen = function (...args) { - var result = oldInit.apply(this, args); - if (App.game && !hasInitialized) { - // Initialize all attached userscripts - Object.entries(windowObject.epheniaScriptInitializers).forEach(([scriptName, initFunction]) => { - try { - initFunction(); - } catch (e) { - reportScriptError(scriptName, e); - } - }); - hasInitialized = true; - } - return result; - } - } - - // Prevent issues with duplicate script names - if (windowObject.epheniaScriptInitializers[scriptName] !== undefined) { - console.warn(`Duplicate '${scriptName}' userscripts found!`); - Notifier.notify({ - type: NotificationConstants.NotificationOption.warning, - title: scriptName, - message: `Duplicate '${scriptName}' userscripts detected. This could cause unpredictable behavior and is not recommended.`, - timeout: GameConstants.DAY, - }); - let number = 2; - while (windowObject.epheniaScriptInitializers[`${scriptName} ${number}`] !== undefined) { - number++; - } - scriptName = `${scriptName} ${number}`; - } - // Add initializer for this particular script - windowObject.epheniaScriptInitializers[scriptName] = initFunction; - // Run any functions that need to execute before the game starts - if (priorityFunction) { - $(document).ready(() => { - try { - priorityFunction(); - } catch (e) { - reportScriptError(scriptName, e); - // Remove main initialization function - windowObject.epheniaScriptInitializers[scriptName] = () => null; - } - }); - } + function reportScriptError(scriptName, error) { + console.error(`Error while initializing '${scriptName}' userscript:\n${error}`); + Notifier.notify({ + type: NotificationConstants.NotificationOption.warning, + title: scriptName, + message: `The '${scriptName}' userscript crashed while loading. Check for updates or disable the script, then restart the game.\n\nReport script issues to the script developer, not to the Pokéclicker team.`, + timeout: GameConstants.DAY, + }); + } + const windowObject = !App.isUsingClient ? unsafeWindow : window; + // Inject handlers if they don't exist yet + if (windowObject.epheniaScriptInitializers === undefined) { + windowObject.epheniaScriptInitializers = {}; + const oldInit = Preload.hideSplashScreen; + var hasInitialized = false; + + // Initializes scripts once enough of the game has loaded + Preload.hideSplashScreen = function (...args) { + var result = oldInit.apply(this, args); + if (App.game && !hasInitialized) { + // Initialize all attached userscripts + Object.entries(windowObject.epheniaScriptInitializers).forEach(([scriptName, initFunction]) => { + try { + initFunction(); + } catch (e) { + reportScriptError(scriptName, e); + } + }); + hasInitialized = true; + } + return result; + } + } + + // Prevent issues with duplicate script names + if (windowObject.epheniaScriptInitializers[scriptName] !== undefined) { + console.warn(`Duplicate '${scriptName}' userscripts found!`); + Notifier.notify({ + type: NotificationConstants.NotificationOption.warning, + title: scriptName, + message: `Duplicate '${scriptName}' userscripts detected. This could cause unpredictable behavior and is not recommended.`, + timeout: GameConstants.DAY, + }); + let number = 2; + while (windowObject.epheniaScriptInitializers[`${scriptName} ${number}`] !== undefined) { + number++; + } + scriptName = `${scriptName} ${number}`; + } + // Add initializer for this particular script + windowObject.epheniaScriptInitializers[scriptName] = initFunction; + // Run any functions that need to execute before the game starts + if (priorityFunction) { + $(document).ready(() => { + try { + priorityFunction(); + } catch (e) { + reportScriptError(scriptName, e); + // Remove main initialization function + windowObject.epheniaScriptInitializers[scriptName] = () => null; + } + }); + } } if (!App.isUsingClient || localStorage.getItem('debugcheatstools') === 'true') { - loadEpheniaScript('debugcheatstools', initSaveEditor); + loadEpheniaScript('debugcheatstools', initSaveEditor); } From f513bec43367099fdb531b495d9917d27e469d82 Mon Sep 17 00:00:00 2001 From: iamc24 <42425100+iamc24@users.noreply.github.com> Date: Wed, 30 Jul 2025 03:59:30 -0700 Subject: [PATCH 10/14] Update debugcheatstools.user.js Fix issue with duplicate event handlers being created, multiplying the amount of currency/items added/removed --- custom/debugcheatstools.user.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/custom/debugcheatstools.user.js b/custom/debugcheatstools.user.js index 6ffab17..5e798cc 100644 --- a/custom/debugcheatstools.user.js +++ b/custom/debugcheatstools.user.js @@ -43,7 +43,6 @@ function gainPk(){ App.game.party.gainPokemonById(id, true); document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[1].src = getPokeballImgSrc(id, lpkm); filterPkdx(); - loadEventHandlers(); } // eslint-disable-next-line no-unused-vars @@ -55,7 +54,6 @@ function gainPkrs(){ lpkm.pokerus = (lpkm.pokerus < 2) ? 2 : 3; document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[2].src = getPokerusImgSrc(id, lpkm); filterPkdx(); - loadEventHandlers(); } function gainCurrency() { @@ -195,7 +193,7 @@ function loadPkdx(){ } pkdxBody.innerHTML = toAdd; filterPkdx(); - loadEventHandlers(); + pkdxLoadEventHandlers(); } function loadQuestLines() { @@ -232,7 +230,6 @@ function loadQuestLines() { qlBody.innerHTML = toAdd; filterQuestLine(); - loadEventHandlers(); } function loadEventHandlers() { @@ -309,19 +306,22 @@ function loadEventHandlers() { document.getElementById("pkdxRegionFilter").addEventListener("change", filterPkdx); document.getElementById("pkdxShinyFilter").addEventListener("change", filterPkdx); document.getElementById("pkdxPKRSFilter").addEventListener("change", filterPkdx); - for (const pokemon of pokemonList) { - let pkElement = document.getElementById("pkdx_" + pokemon.id.toString().replace('.','_')); - if (pkElement){ - pkElement.children[4].addEventListener("click", gainPk); - pkElement.children[5].addEventListener("click", gainPkrs); - } - } // questline document.getElementById("questlines").children[1].addEventListener("click", loadQuestLines); document.getElementById("questLineFilter").addEventListener("change", filterQuestLine); } +function pkdxLoadEventHandlers() { + for (const pokemon of pokemonList) { + let pkElement = document.getElementById("pkdx_" + pokemon.id.toString().replace('.','_')); + if (pkElement){ + pkElement.children[4].addEventListener("click", gainPk); + pkElement.children[5].addEventListener("click", gainPkrs); + } + } +} + function initSaveEditor() { // Add menu item let eventLi = document.createElement('li'); From 2b9f397d0d8f34994265a99843fb02af8e2840c3 Mon Sep 17 00:00:00 2001 From: iamc24 <42425100+iamc24@users.noreply.github.com> Date: Wed, 30 Jul 2025 16:18:56 -0700 Subject: [PATCH 11/14] Update debugcheatstools.user.js Slightly simplify more event handlers; Fix evolution item name capitalization; Capitalize held items tab name; Improve consistency between ids and comments for evolution/held items --- custom/debugcheatstools.user.js | 1206 ++++++++++++++++--------------- 1 file changed, 604 insertions(+), 602 deletions(-) diff --git a/custom/debugcheatstools.user.js b/custom/debugcheatstools.user.js index 5e798cc..809ce8d 100644 --- a/custom/debugcheatstools.user.js +++ b/custom/debugcheatstools.user.js @@ -24,292 +24,292 @@ const profileDrop = document.getElementById('startMenu').querySelectorAll('ul li const profileModal = document.getElementById('profileModal'); function getPokerusImgSrc(id, pkm){ - let lpkm = pkm || App.game.party.getPokemon(id); - return lpkm?.pokerus || 0 > 0 ? (lpkm.pokerus === 3 ? "assets/images/breeding/pokerus/Resistant.png" : "assets/images/breeding/pokerus/Contagious.png") : "assets/images/breeding/pokerus/Infected.png"; + let lpkm = pkm || App.game.party.getPokemon(id); + return lpkm?.pokerus || 0 > 0 ? (lpkm.pokerus === 3 ? "assets/images/breeding/pokerus/Resistant.png" : "assets/images/breeding/pokerus/Contagious.png") : "assets/images/breeding/pokerus/Infected.png"; } function getPokeballImgSrc(id, pkm){ - let lpkm = pkm || App.game.party.getPokemon(id); - return lpkm ? ((lpkm?.shiny === true) ? "assets/images/pokeball/Pokeball-shiny.svg" : "assets/images/pokeball/Pokeball.svg") : "assets/images/pokeball/None.svg"; + let lpkm = pkm || App.game.party.getPokemon(id); + return lpkm ? ((lpkm?.shiny === true) ? "assets/images/pokeball/Pokeball-shiny.svg" : "assets/images/pokeball/Pokeball.svg") : "assets/images/pokeball/None.svg"; } // eslint-disable-next-line no-unused-vars function gainPk(){ - let id = parseFloat(this.parentElement.children[0].innerHTML); - let lpkm = App.game.party.getPokemon(id); - if (!lpkm) - App.game.party.gainPokemonById(id) - else if (!(lpkm?.shiny === true)) - App.game.party.gainPokemonById(id, true); - document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[1].src = getPokeballImgSrc(id, lpkm); - filterPkdx(); + let id = parseFloat(this.parentElement.children[0].innerHTML); + let lpkm = App.game.party.getPokemon(id); + if (!lpkm) + App.game.party.gainPokemonById(id) + else if (!(lpkm?.shiny === true)) + App.game.party.gainPokemonById(id, true); + document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[1].src = getPokeballImgSrc(id, lpkm); + filterPkdx(); } // eslint-disable-next-line no-unused-vars function gainPkrs(){ - let id = parseFloat(this.parentElement.children[0].innerHTML); - let lpkm = App.game.party.getPokemon(id); - if (!lpkm) return; - lpkm.effortPoints = ((lpkm.pokerus < 2) ? 1 : 50) * 1000; // strange - lpkm.pokerus = (lpkm.pokerus < 2) ? 2 : 3; - document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[2].src = getPokerusImgSrc(id, lpkm); - filterPkdx(); + let id = parseFloat(this.parentElement.children[0].innerHTML); + let lpkm = App.game.party.getPokemon(id); + if (!lpkm) return; + lpkm.effortPoints = ((lpkm.pokerus < 2) ? 1 : 50) * 1000; // strange + lpkm.pokerus = (lpkm.pokerus < 2) ? 2 : 3; + document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[2].src = getPokerusImgSrc(id, lpkm); + filterPkdx(); } function gainCurrency() { - let currency = parseInt(this.getAttribute("currency")); - let changeAmount = parseInt(document.getElementById("inputAddCurrency").value || 0); - if (changeAmount > 0) { - App.game.wallet.addAmount(new Amount(changeAmount,currency),true); - } else if (changeAmount < 0) { - changeAmount = Math.abs(changeAmount); - if (changeAmount > App.game.wallet.currencies[currency]()) { - changeAmount = App.game.wallet.currencies[currency](); - if (changeAmount == 0) { - return; - } - } - App.game.wallet.loseAmount(new Amount(changeAmount,currency)); - } + let currency = parseInt(this.getAttribute("currency")); + let changeAmount = parseInt(document.getElementById("inputAddCurrency").value || 0); + if (changeAmount > 0) { + App.game.wallet.addAmount(new Amount(changeAmount,currency),true); + } else if (changeAmount < 0) { + changeAmount = Math.abs(changeAmount); + if (changeAmount > App.game.wallet.currencies[currency]()) { + changeAmount = App.game.wallet.currencies[currency](); + if (changeAmount == 0) { + return; + } + } + App.game.wallet.loseAmount(new Amount(changeAmount,currency)); + } } function filterPkdx(){ - let lst = document.querySelectorAll(':scope #pkdx tbody tr'); - for (let i = 0; i < lst.length; i++) { - const tdb = lst[i]; - let display = true; - - if (document.getElementById('pkdxNameFilter').value !== ""){ - display = tdb.innerHTML.match(/.*<\/td>/g)[3].toLowerCase().includes(document.getElementById('pkdxNameFilter').value.toLowerCase()); - } - - if (display === true) { - switch (document.getElementById('pkdxRegionFilter').value) { - case 'all': - break; - default: - display = tdb.innerHTML.match(/.*<\/td>/g)[1].toLowerCase().includes(document.getElementById('pkdxRegionFilter').value); - break; - } - } - - if (display === true) { - switch (document.getElementById('pkdxShinyFilter').value) { - case 'uncaught': - display = tdb.innerHTML.includes('None.svg'); - break; - case 'caught': - display = tdb.innerHTML.includes('Pokeball.svg') || tdb.innerHTML.includes('Pokeball-shiny.svg'); - break; - case 'caught-not-shiny': - display = tdb.innerHTML.includes('Pokeball.svg'); - break; - case 'caught-shiny': - display = tdb.innerHTML.includes('Pokeball-shiny.svg'); - break; - default: - break; - } - } - - if (display === true) { - switch (document.getElementById('pkdxPKRSFilter').value) { - case '0': - display = tdb.innerHTML.includes('Infected.png'); - break; - case '2': - display = tdb.innerHTML.includes('Contagious.png'); - break; - case '3': - display = tdb.innerHTML.includes('Resistant.png'); - break; - default: - break; - } - } - - tdb.style.display = (display === true ? "" : "none"); - } + let lst = document.querySelectorAll(':scope #pkdx tbody tr'); + for (let i = 0; i < lst.length; i++) { + const tdb = lst[i]; + let display = true; + + if (document.getElementById('pkdxNameFilter').value !== ""){ + display = tdb.innerHTML.match(/.*<\/td>/g)[3].toLowerCase().includes(document.getElementById('pkdxNameFilter').value.toLowerCase()); + } + + if (display === true) { + switch (document.getElementById('pkdxRegionFilter').value) { + case 'all': + break; + default: + display = tdb.innerHTML.match(/.*<\/td>/g)[1].toLowerCase().includes(document.getElementById('pkdxRegionFilter').value); + break; + } + } + + if (display === true) { + switch (document.getElementById('pkdxShinyFilter').value) { + case 'uncaught': + display = tdb.innerHTML.includes('None.svg'); + break; + case 'caught': + display = tdb.innerHTML.includes('Pokeball.svg') || tdb.innerHTML.includes('Pokeball-shiny.svg'); + break; + case 'caught-not-shiny': + display = tdb.innerHTML.includes('Pokeball.svg'); + break; + case 'caught-shiny': + display = tdb.innerHTML.includes('Pokeball-shiny.svg'); + break; + default: + break; + } + } + + if (display === true) { + switch (document.getElementById('pkdxPKRSFilter').value) { + case '0': + display = tdb.innerHTML.includes('Infected.png'); + break; + case '2': + display = tdb.innerHTML.includes('Contagious.png'); + break; + case '3': + display = tdb.innerHTML.includes('Resistant.png'); + break; + default: + break; + } + } + + tdb.style.display = (display === true ? "" : "none"); + } } function filterQuestLine(){ - let lst = document.querySelectorAll(':scope #questlinelist tbody tr'); - for (let i = 0; i < lst.length; i++) { - const tdb = lst[i]; - let display = true; - - if (display === true) { - switch (document.getElementById('questLineFilter').value) { - case 'all': - break; - default: - display = tdb.innerHTML.toLowerCase().includes(document.getElementById('questLineFilter').value); - break; - } - } - - tdb.style.display = (display === true ? "" : "none"); - } + let lst = document.querySelectorAll(':scope #questlinelist tbody tr'); + for (let i = 0; i < lst.length; i++) { + const tdb = lst[i]; + let display = true; + + if (display === true) { + switch (document.getElementById('questLineFilter').value) { + case 'all': + break; + default: + display = tdb.innerHTML.toLowerCase().includes(document.getElementById('questLineFilter').value); + break; + } + } + + tdb.style.display = (display === true ? "" : "none"); + } } // eslint-disable-next-line no-unused-vars function loadPkdx(){ - let playerRegion = player.highestRegion(); - let pkdxBody = document.querySelector(':scope #pkdx tbody'); - pkdxBody.innerHTML = ''; - let toAdd = ""; - for (const pokemon of pokemonList) { - if ((pokemon.nativeRegion <= playerRegion && pokemon.nativeRegion > -1) || (pokemon.nativeRegion == -1 && playerRegion >= GameConstants.Region.alola) || pokemon.id == 0) { - let lpkm = App.game.party.getPokemon(pokemon.id); - let region = GameConstants.Region[pokemon.nativeRegion].charAt(0).toUpperCase() + GameConstants.Region[pokemon.nativeRegion].slice(1); - let hint = ""; - let getPokemonLocation = PokemonLocations.getPokemonLocations(pokemon.name, playerRegion); - let roadLocations = getPokemonLocation[0] - if (roadLocations) { - for (let i = 0; i <= playerRegion; i++) { - const reg = GameConstants.Region[i]; - let roads = "Route" - roadLocations[i]?.forEach((route) => { - roads += ` ${route.route},` - }); - if (roads !== "Route") - hint += `${hint !== "" ? `\n` : ""}${reg.charAt(0).toUpperCase() + reg.slice(1)}: ${roads.slice(0, -1)}`; - } - if (hint !== "") - hint = ` title="${hint}"`; - } - toAdd += ` - - ${pokemon.id} - ${region} - - ${pokemon.name} - - - YES') : '194, 46, 40);">NO'} - - `; - } - } - pkdxBody.innerHTML = toAdd; - filterPkdx(); - pkdxLoadEventHandlers(); + let playerRegion = player.highestRegion(); + let pkdxBody = document.querySelector(':scope #pkdx tbody'); + pkdxBody.innerHTML = ''; + let toAdd = ""; + for (const pokemon of pokemonList) { + if ((pokemon.nativeRegion <= playerRegion && pokemon.nativeRegion > -1) || (pokemon.nativeRegion == -1 && playerRegion >= GameConstants.Region.alola) || pokemon.id == 0) { + let lpkm = App.game.party.getPokemon(pokemon.id); + let region = GameConstants.Region[pokemon.nativeRegion].charAt(0).toUpperCase() + GameConstants.Region[pokemon.nativeRegion].slice(1); + let hint = ""; + let getPokemonLocation = PokemonLocations.getPokemonLocations(pokemon.name, playerRegion); + let roadLocations = getPokemonLocation[0] + if (roadLocations) { + for (let i = 0; i <= playerRegion; i++) { + const reg = GameConstants.Region[i]; + let roads = "Route" + roadLocations[i]?.forEach((route) => { + roads += ` ${route.route},` + }); + if (roads !== "Route") + hint += `${hint !== "" ? `\n` : ""}${reg.charAt(0).toUpperCase() + reg.slice(1)}: ${roads.slice(0, -1)}`; + } + if (hint !== "") + hint = ` title="${hint}"`; + } + toAdd += ` + + ${pokemon.id} + ${region} + + ${pokemon.name} + + + YES') : '194, 46, 40);">NO'} + + `; + } + } + pkdxBody.innerHTML = toAdd; + filterPkdx(); + pkdxLoadEventHandlers(); } function loadQuestLines() { - let qlBody = document.querySelector(':scope #questlinelist tbody'); - qlBody.innerHTML = ''; - let toAdd = ""; - - for (const ql of App.game.quests.questLines()) { - let state = QuestLineState[ql.state()] - state = state.charAt(0).toUpperCase() + state.slice(1) - - let stateColor; - switch (ql.state()) { - case 0: - stateColor = "244, 80, 80"; - break; - case 1: - stateColor = "99, 144, 240"; - break; - case 2: - stateColor = "122, 199, 76"; - break; - } - - toAdd += ` - - ${ql.name} - ${state} - - `; - } - - // App.game.quests.questLines().filter(e => e.state() < 2).forEach(e => console.log(e.name, e.state())) - - qlBody.innerHTML = toAdd; - filterQuestLine(); + let qlBody = document.querySelector(':scope #questlinelist tbody'); + qlBody.innerHTML = ''; + let toAdd = ""; + + for (const ql of App.game.quests.questLines()) { + let state = QuestLineState[ql.state()] + state = state.charAt(0).toUpperCase() + state.slice(1) + + let stateColor; + switch (ql.state()) { + case 0: + stateColor = "244, 80, 80"; + break; + case 1: + stateColor = "99, 144, 240"; + break; + case 2: + stateColor = "122, 199, 76"; + break; + } + + toAdd += ` + + ${ql.name} + ${state} + + `; + } + + // App.game.quests.questLines().filter(e => e.state() < 2).forEach(e => console.log(e.name, e.state())) + + qlBody.innerHTML = toAdd; + filterQuestLine(); } function loadEventHandlers() { - // currency - for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { - document.getElementById("currency_" + i).addEventListener("click", gainCurrency); - } - - // gems - for (let i = 0; i < Gems.nTypes; i++) { - document.getElementById("gems_" + i).addEventListener("click", function () { - App.game.gems.gainGems(parseInt(document.getElementById('inputAddGems').value || 0), i); - }); - } - - // pokeballs - for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { - document.getElementById("pokeballs_" + i).addEventListener("click", function () { - App.game.pokeballs.gainPokeballs(i, parseInt(document.getElementById('inputAddPokeballs').value || 0), true); - }); - } - - // berries - for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { - document.getElementById("berries_" + i).addEventListener("click", function () { - App.game.farming.gainBerry(i, parseInt(document.getElementById('inputAddBerries').value || 0), true); - }); - } - - // evolutionitems - for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { - document.getElementById("evolutionitems_" + i).addEventListener("click", function () { - player.gainItem(ItemList[this.getAttribute("item")].name, parseInt(document.getElementById('inputAddEvolutionItems').value || 0), true); - }); - } - - // vitamins - for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { - document.getElementById("vitamins_" + i).addEventListener("click", function () { - player.gainItem(ItemList[this.getAttribute("vitamin")].name, parseInt(document.getElementById('inputAddVitamins').value || 0), true); - }); - } - - // heldItems - HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { - document.getElementById("attackhelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().attack.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { - document.getElementById("typehelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().typeRestricted.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { - document.getElementById("evhelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().ev.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { - document.getElementById("exphelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().exp.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { - document.getElementById("otherhelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().other.items[parseInt(this.getAttribute("item"))].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - - // pokedex - document.getElementById("pokedex").children[1].addEventListener("click", loadPkdx); - document.getElementById("pkdxNameFilter").addEventListener("input", filterPkdx); - document.getElementById("pkdxRegionFilter").addEventListener("change", filterPkdx); - document.getElementById("pkdxShinyFilter").addEventListener("change", filterPkdx); - document.getElementById("pkdxPKRSFilter").addEventListener("change", filterPkdx); - - // questline - document.getElementById("questlines").children[1].addEventListener("click", loadQuestLines); - document.getElementById("questLineFilter").addEventListener("change", filterQuestLine); + // currency + for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { + document.getElementById("currency_" + i).addEventListener("click", gainCurrency); + } + + // gems + for (let i = 0; i < Gems.nTypes; i++) { + document.getElementById("gems_" + i).addEventListener("click", function () { + App.game.gems.gainGems(parseInt(document.getElementById('inputAddGems').value || 0), i); + }); + } + + // pokeballs + for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { + document.getElementById("pokeballs_" + i).addEventListener("click", function () { + App.game.pokeballs.gainPokeballs(i, parseInt(document.getElementById('inputAddPokeballs').value || 0), true); + }); + } + + // berries + for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { + document.getElementById("berries_" + i).addEventListener("click", function () { + App.game.farming.gainBerry(i, parseInt(document.getElementById('inputAddBerries').value || 0), true); + }); + } + + // evolution items + for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { + document.getElementById("evolutionitems_" + i).addEventListener("click", function () { + player.gainItem(this.getAttribute("item"), parseInt(document.getElementById('inputAddEvolutionItems').value || 0), true); + }); + } + + // vitamins + for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { + document.getElementById("vitamins_" + i).addEventListener("click", function () { + player.gainItem(this.getAttribute("vitamin"), parseInt(document.getElementById('inputAddVitamins').value || 0), true); + }); + } + + // held items + HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { + document.getElementById("attackhelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().attack.items[idk].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { + document.getElementById("typehelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().typeRestricted.items[idx].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { + document.getElementById("evhelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().ev.items[idx].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { + document.getElementById("exphelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().exp.items[idx].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { + document.getElementById("otherhelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().other.items[idx].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + + // pokedex + document.getElementById("pokedex").children[1].addEventListener("click", loadPkdx); + document.getElementById("pkdxNameFilter").addEventListener("input", filterPkdx); + document.getElementById("pkdxRegionFilter").addEventListener("change", filterPkdx); + document.getElementById("pkdxShinyFilter").addEventListener("change", filterPkdx); + document.getElementById("pkdxPKRSFilter").addEventListener("change", filterPkdx); + + // questline + document.getElementById("questlines").children[1].addEventListener("click", loadQuestLines); + document.getElementById("questLineFilter").addEventListener("change", filterQuestLine); } function pkdxLoadEventHandlers() { @@ -323,293 +323,295 @@ function pkdxLoadEventHandlers() { } function initSaveEditor() { - // Add menu item - let eventLi = document.createElement('li'); - eventLi.innerHTML = `Debug Cheats` - profileDrop.before(eventLi); - - // Add popup - let eventMod = document.createElement('div'); - eventMod.setAttribute("class", "modal noselect fade show"); - eventMod.setAttribute("id", "saveEditorModal"); - eventMod.setAttribute("tabindex", "-1"); - eventMod.setAttribute("aria-labelledby", "saveEditorModal"); - eventMod.setAttribute("aria-modal", "true"); - eventMod.setAttribute("role", "dialog"); - - eventMod.innerHTML = ` - - `; - - profileModal.before(eventMod); - - let modalBody = document.querySelector('[id=saveEditorModal] div div [class=modal-body]'); - - // currency - for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { - const itm = GameConstants.Currency[i]; - const itmPretty = itm.charAt(0).toUpperCase() + itm.replace(/[A-Z]/g, ' $&').trim().slice(1); - modalBody.querySelector('#currency').innerHTML += ` -
- -
${itmPretty}
-
- `; - } - - // gems - for (let i = 0; i < Gems.nTypes; i++) { - const itm = PokemonType[i]; - modalBody.querySelector('#gems').innerHTML += ` -
- -
${itm}
-
- `; - } - - // pokeballs - for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { - const itm = GameConstants.Pokeball[i]; - modalBody.querySelector('#pokeballs').innerHTML += ` -
- -
${itm}
-
- `; - } - - // berries - for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { - const itm = BerryType[i]; - modalBody.querySelector('#berries').innerHTML += ` -
- -
${itm}
-
- `; - } - - // evolutionitems - for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { - const itm = GameConstants.StoneType[i]; - const itmPretty = itm.replaceAll('_', ' '); - modalBody.querySelector('#evolutionitems').innerHTML += ` -
- -
${itmPretty}
-
- `; - } - - // vitamins - for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { - const itm = GameConstants.VitaminType[i]; - modalBody.querySelector('#vitamins').innerHTML += ` -
- -
${itm}
-
- `; - } - - // heldItems - HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - - // pokedex - const pkdxRegFilt = modalBody.querySelector('#pkdxRegionFilter'); - for (let i = 0; i <= player.highestRegion(); i++) { - const reg = GameConstants.Region[i] - pkdxRegFilt.innerHTML += ``; - } - pkdxRegFilt.innerHTML += ''; - - - loadEventHandlers(); + // Add menu item + let eventLi = document.createElement('li'); + eventLi.innerHTML = `Debug Cheats` + profileDrop.before(eventLi); + + // Add popup + let eventMod = document.createElement('div'); + eventMod.setAttribute("class", "modal noselect fade show"); + eventMod.setAttribute("id", "saveEditorModal"); + eventMod.setAttribute("tabindex", "-1"); + eventMod.setAttribute("aria-labelledby", "saveEditorModal"); + eventMod.setAttribute("aria-modal", "true"); + eventMod.setAttribute("role", "dialog"); + + eventMod.innerHTML = ` + + `; + + profileModal.before(eventMod); + + let modalBody = document.querySelector('[id=saveEditorModal] div div [class=modal-body]'); + + // currency + for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { + const itm = GameConstants.Currency[i]; + const itmPretty = itm.charAt(0).toUpperCase() + itm.replace(/[A-Z]/g, ' $&').trim().slice(1); + modalBody.querySelector('#currency').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + } + + // gems + for (let i = 0; i < Gems.nTypes; i++) { + const itm = PokemonType[i]; + modalBody.querySelector('#gems').innerHTML += ` +
+ +
${itm}
+
+ `; + } + + // pokeballs + for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { + const itm = GameConstants.Pokeball[i]; + modalBody.querySelector('#pokeballs').innerHTML += ` +
+ +
${itm}
+
+ `; + } + + // berries + for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { + const itm = BerryType[i]; + modalBody.querySelector('#berries').innerHTML += ` +
+ +
${itm}
+
+ `; + } + + // evolution items + for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { + const itm = GameConstants.StoneType[i]; + const itmPretty = itm.replaceAll('_', ' ').replace(/\b\w/g, function(char) { + return char.toUpperCase(); + }); + modalBody.querySelector('#evolutionItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + } + + // vitamins + for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { + const itm = GameConstants.VitaminType[i]; + modalBody.querySelector('#vitamins').innerHTML += ` +
+ +
${itm}
+
+ `; + } + + // held items + HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + + // pokedex + const pkdxRegFilt = modalBody.querySelector('#pkdxRegionFilter'); + for (let i = 0; i <= player.highestRegion(); i++) { + const reg = GameConstants.Region[i] + pkdxRegFilt.innerHTML += ``; + } + pkdxRegFilt.innerHTML += ''; + + + loadEventHandlers(); } /* WIP, sevii helper var lst = pokemonList.filter((p) => p.name.includes('Pinkan') - || p.name.includes('Valencian') - || p.name === 'Crystal Onix' - || p.name === 'Ash\'s Butterfree' - || p.name === 'Pink Butterfree'); + || p.name.includes('Valencian') + || p.name === 'Crystal Onix' + || p.name === 'Ash\'s Butterfree' + || p.name === 'Pink Butterfree'); var caught = App.game.party.caughtPokemon - .filter((p) => p.name.includes('Pinkan') - || p.name.includes('Valencian') - || p.name === 'Crystal Onix' - || p.name === 'Ash\'s Butterfree' - || p.name === 'Pink Butterfree'); + .filter((p) => p.name.includes('Pinkan') + || p.name.includes('Valencian') + || p.name === 'Crystal Onix' + || p.name === 'Ash\'s Butterfree' + || p.name === 'Pink Butterfree'); var caughtNames = caught.map(e => e.name); var missing = lst.filter(e => !caughtNames.includes(e.name)); @@ -618,71 +620,71 @@ console.log(missing); */ function loadEpheniaScript(scriptName, initFunction, priorityFunction) { - function reportScriptError(scriptName, error) { - console.error(`Error while initializing '${scriptName}' userscript:\n${error}`); - Notifier.notify({ - type: NotificationConstants.NotificationOption.warning, - title: scriptName, - message: `The '${scriptName}' userscript crashed while loading. Check for updates or disable the script, then restart the game.\n\nReport script issues to the script developer, not to the Pokéclicker team.`, - timeout: GameConstants.DAY, - }); - } - const windowObject = !App.isUsingClient ? unsafeWindow : window; - // Inject handlers if they don't exist yet - if (windowObject.epheniaScriptInitializers === undefined) { - windowObject.epheniaScriptInitializers = {}; - const oldInit = Preload.hideSplashScreen; - var hasInitialized = false; - - // Initializes scripts once enough of the game has loaded - Preload.hideSplashScreen = function (...args) { - var result = oldInit.apply(this, args); - if (App.game && !hasInitialized) { - // Initialize all attached userscripts - Object.entries(windowObject.epheniaScriptInitializers).forEach(([scriptName, initFunction]) => { - try { - initFunction(); - } catch (e) { - reportScriptError(scriptName, e); - } - }); - hasInitialized = true; - } - return result; - } - } - - // Prevent issues with duplicate script names - if (windowObject.epheniaScriptInitializers[scriptName] !== undefined) { - console.warn(`Duplicate '${scriptName}' userscripts found!`); - Notifier.notify({ - type: NotificationConstants.NotificationOption.warning, - title: scriptName, - message: `Duplicate '${scriptName}' userscripts detected. This could cause unpredictable behavior and is not recommended.`, - timeout: GameConstants.DAY, - }); - let number = 2; - while (windowObject.epheniaScriptInitializers[`${scriptName} ${number}`] !== undefined) { - number++; - } - scriptName = `${scriptName} ${number}`; - } - // Add initializer for this particular script - windowObject.epheniaScriptInitializers[scriptName] = initFunction; - // Run any functions that need to execute before the game starts - if (priorityFunction) { - $(document).ready(() => { - try { - priorityFunction(); - } catch (e) { - reportScriptError(scriptName, e); - // Remove main initialization function - windowObject.epheniaScriptInitializers[scriptName] = () => null; - } - }); - } + function reportScriptError(scriptName, error) { + console.error(`Error while initializing '${scriptName}' userscript:\n${error}`); + Notifier.notify({ + type: NotificationConstants.NotificationOption.warning, + title: scriptName, + message: `The '${scriptName}' userscript crashed while loading. Check for updates or disable the script, then restart the game.\n\nReport script issues to the script developer, not to the Pokéclicker team.`, + timeout: GameConstants.DAY, + }); + } + const windowObject = !App.isUsingClient ? unsafeWindow : window; + // Inject handlers if they don't exist yet + if (windowObject.epheniaScriptInitializers === undefined) { + windowObject.epheniaScriptInitializers = {}; + const oldInit = Preload.hideSplashScreen; + var hasInitialized = false; + + // Initializes scripts once enough of the game has loaded + Preload.hideSplashScreen = function (...args) { + var result = oldInit.apply(this, args); + if (App.game && !hasInitialized) { + // Initialize all attached userscripts + Object.entries(windowObject.epheniaScriptInitializers).forEach(([scriptName, initFunction]) => { + try { + initFunction(); + } catch (e) { + reportScriptError(scriptName, e); + } + }); + hasInitialized = true; + } + return result; + } + } + + // Prevent issues with duplicate script names + if (windowObject.epheniaScriptInitializers[scriptName] !== undefined) { + console.warn(`Duplicate '${scriptName}' userscripts found!`); + Notifier.notify({ + type: NotificationConstants.NotificationOption.warning, + title: scriptName, + message: `Duplicate '${scriptName}' userscripts detected. This could cause unpredictable behavior and is not recommended.`, + timeout: GameConstants.DAY, + }); + let number = 2; + while (windowObject.epheniaScriptInitializers[`${scriptName} ${number}`] !== undefined) { + number++; + } + scriptName = `${scriptName} ${number}`; + } + // Add initializer for this particular script + windowObject.epheniaScriptInitializers[scriptName] = initFunction; + // Run any functions that need to execute before the game starts + if (priorityFunction) { + $(document).ready(() => { + try { + priorityFunction(); + } catch (e) { + reportScriptError(scriptName, e); + // Remove main initialization function + windowObject.epheniaScriptInitializers[scriptName] = () => null; + } + }); + } } if (!App.isUsingClient || localStorage.getItem('debugcheatstools') === 'true') { - loadEpheniaScript('debugcheatstools', initSaveEditor); + loadEpheniaScript('debugcheatstools', initSaveEditor); } From 3a983e6fbe7dc388f997bebc911e3a8cec2d1877 Mon Sep 17 00:00:00 2001 From: iamc24 <42425100+iamc24@users.noreply.github.com> Date: Wed, 30 Jul 2025 16:20:38 -0700 Subject: [PATCH 12/14] Update debugcheatstools.user.js Fix indentation --- custom/debugcheatstools.user.js | 1222 +++++++++++++++---------------- 1 file changed, 611 insertions(+), 611 deletions(-) diff --git a/custom/debugcheatstools.user.js b/custom/debugcheatstools.user.js index 809ce8d..602b5bb 100644 --- a/custom/debugcheatstools.user.js +++ b/custom/debugcheatstools.user.js @@ -24,594 +24,594 @@ const profileDrop = document.getElementById('startMenu').querySelectorAll('ul li const profileModal = document.getElementById('profileModal'); function getPokerusImgSrc(id, pkm){ - let lpkm = pkm || App.game.party.getPokemon(id); - return lpkm?.pokerus || 0 > 0 ? (lpkm.pokerus === 3 ? "assets/images/breeding/pokerus/Resistant.png" : "assets/images/breeding/pokerus/Contagious.png") : "assets/images/breeding/pokerus/Infected.png"; + let lpkm = pkm || App.game.party.getPokemon(id); + return lpkm?.pokerus || 0 > 0 ? (lpkm.pokerus === 3 ? "assets/images/breeding/pokerus/Resistant.png" : "assets/images/breeding/pokerus/Contagious.png") : "assets/images/breeding/pokerus/Infected.png"; } function getPokeballImgSrc(id, pkm){ - let lpkm = pkm || App.game.party.getPokemon(id); - return lpkm ? ((lpkm?.shiny === true) ? "assets/images/pokeball/Pokeball-shiny.svg" : "assets/images/pokeball/Pokeball.svg") : "assets/images/pokeball/None.svg"; + let lpkm = pkm || App.game.party.getPokemon(id); + return lpkm ? ((lpkm?.shiny === true) ? "assets/images/pokeball/Pokeball-shiny.svg" : "assets/images/pokeball/Pokeball.svg") : "assets/images/pokeball/None.svg"; } // eslint-disable-next-line no-unused-vars function gainPk(){ - let id = parseFloat(this.parentElement.children[0].innerHTML); - let lpkm = App.game.party.getPokemon(id); - if (!lpkm) - App.game.party.gainPokemonById(id) - else if (!(lpkm?.shiny === true)) - App.game.party.gainPokemonById(id, true); - document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[1].src = getPokeballImgSrc(id, lpkm); - filterPkdx(); + let id = parseFloat(this.parentElement.children[0].innerHTML); + let lpkm = App.game.party.getPokemon(id); + if (!lpkm) + App.game.party.gainPokemonById(id) + else if (!(lpkm?.shiny === true)) + App.game.party.gainPokemonById(id, true); + document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[1].src = getPokeballImgSrc(id, lpkm); + filterPkdx(); } // eslint-disable-next-line no-unused-vars function gainPkrs(){ - let id = parseFloat(this.parentElement.children[0].innerHTML); - let lpkm = App.game.party.getPokemon(id); - if (!lpkm) return; - lpkm.effortPoints = ((lpkm.pokerus < 2) ? 1 : 50) * 1000; // strange - lpkm.pokerus = (lpkm.pokerus < 2) ? 2 : 3; - document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[2].src = getPokerusImgSrc(id, lpkm); - filterPkdx(); + let id = parseFloat(this.parentElement.children[0].innerHTML); + let lpkm = App.game.party.getPokemon(id); + if (!lpkm) return; + lpkm.effortPoints = ((lpkm.pokerus < 2) ? 1 : 50) * 1000; // strange + lpkm.pokerus = (lpkm.pokerus < 2) ? 2 : 3; + document.querySelectorAll(`:scope #pkdx_${id.toString().replace('.','_')} img`)[2].src = getPokerusImgSrc(id, lpkm); + filterPkdx(); } function gainCurrency() { - let currency = parseInt(this.getAttribute("currency")); - let changeAmount = parseInt(document.getElementById("inputAddCurrency").value || 0); - if (changeAmount > 0) { - App.game.wallet.addAmount(new Amount(changeAmount,currency),true); - } else if (changeAmount < 0) { - changeAmount = Math.abs(changeAmount); - if (changeAmount > App.game.wallet.currencies[currency]()) { - changeAmount = App.game.wallet.currencies[currency](); - if (changeAmount == 0) { - return; - } - } - App.game.wallet.loseAmount(new Amount(changeAmount,currency)); - } + let currency = parseInt(this.getAttribute("currency")); + let changeAmount = parseInt(document.getElementById("inputAddCurrency").value || 0); + if (changeAmount > 0) { + App.game.wallet.addAmount(new Amount(changeAmount,currency),true); + } else if (changeAmount < 0) { + changeAmount = Math.abs(changeAmount); + if (changeAmount > App.game.wallet.currencies[currency]()) { + changeAmount = App.game.wallet.currencies[currency](); + if (changeAmount == 0) { + return; + } + } + App.game.wallet.loseAmount(new Amount(changeAmount,currency)); + } } function filterPkdx(){ - let lst = document.querySelectorAll(':scope #pkdx tbody tr'); - for (let i = 0; i < lst.length; i++) { - const tdb = lst[i]; - let display = true; - - if (document.getElementById('pkdxNameFilter').value !== ""){ - display = tdb.innerHTML.match(/.*<\/td>/g)[3].toLowerCase().includes(document.getElementById('pkdxNameFilter').value.toLowerCase()); - } - - if (display === true) { - switch (document.getElementById('pkdxRegionFilter').value) { - case 'all': - break; - default: - display = tdb.innerHTML.match(/.*<\/td>/g)[1].toLowerCase().includes(document.getElementById('pkdxRegionFilter').value); - break; - } - } - - if (display === true) { - switch (document.getElementById('pkdxShinyFilter').value) { - case 'uncaught': - display = tdb.innerHTML.includes('None.svg'); - break; - case 'caught': - display = tdb.innerHTML.includes('Pokeball.svg') || tdb.innerHTML.includes('Pokeball-shiny.svg'); - break; - case 'caught-not-shiny': - display = tdb.innerHTML.includes('Pokeball.svg'); - break; - case 'caught-shiny': - display = tdb.innerHTML.includes('Pokeball-shiny.svg'); - break; - default: - break; - } - } - - if (display === true) { - switch (document.getElementById('pkdxPKRSFilter').value) { - case '0': - display = tdb.innerHTML.includes('Infected.png'); - break; - case '2': - display = tdb.innerHTML.includes('Contagious.png'); - break; - case '3': - display = tdb.innerHTML.includes('Resistant.png'); - break; - default: - break; - } - } - - tdb.style.display = (display === true ? "" : "none"); - } + let lst = document.querySelectorAll(':scope #pkdx tbody tr'); + for (let i = 0; i < lst.length; i++) { + const tdb = lst[i]; + let display = true; + + if (document.getElementById('pkdxNameFilter').value !== ""){ + display = tdb.innerHTML.match(/.*<\/td>/g)[3].toLowerCase().includes(document.getElementById('pkdxNameFilter').value.toLowerCase()); + } + + if (display === true) { + switch (document.getElementById('pkdxRegionFilter').value) { + case 'all': + break; + default: + display = tdb.innerHTML.match(/.*<\/td>/g)[1].toLowerCase().includes(document.getElementById('pkdxRegionFilter').value); + break; + } + } + + if (display === true) { + switch (document.getElementById('pkdxShinyFilter').value) { + case 'uncaught': + display = tdb.innerHTML.includes('None.svg'); + break; + case 'caught': + display = tdb.innerHTML.includes('Pokeball.svg') || tdb.innerHTML.includes('Pokeball-shiny.svg'); + break; + case 'caught-not-shiny': + display = tdb.innerHTML.includes('Pokeball.svg'); + break; + case 'caught-shiny': + display = tdb.innerHTML.includes('Pokeball-shiny.svg'); + break; + default: + break; + } + } + + if (display === true) { + switch (document.getElementById('pkdxPKRSFilter').value) { + case '0': + display = tdb.innerHTML.includes('Infected.png'); + break; + case '2': + display = tdb.innerHTML.includes('Contagious.png'); + break; + case '3': + display = tdb.innerHTML.includes('Resistant.png'); + break; + default: + break; + } + } + + tdb.style.display = (display === true ? "" : "none"); + } } function filterQuestLine(){ - let lst = document.querySelectorAll(':scope #questlinelist tbody tr'); - for (let i = 0; i < lst.length; i++) { - const tdb = lst[i]; - let display = true; - - if (display === true) { - switch (document.getElementById('questLineFilter').value) { - case 'all': - break; - default: - display = tdb.innerHTML.toLowerCase().includes(document.getElementById('questLineFilter').value); - break; - } - } - - tdb.style.display = (display === true ? "" : "none"); - } + let lst = document.querySelectorAll(':scope #questlinelist tbody tr'); + for (let i = 0; i < lst.length; i++) { + const tdb = lst[i]; + let display = true; + + if (display === true) { + switch (document.getElementById('questLineFilter').value) { + case 'all': + break; + default: + display = tdb.innerHTML.toLowerCase().includes(document.getElementById('questLineFilter').value); + break; + } + } + + tdb.style.display = (display === true ? "" : "none"); + } } // eslint-disable-next-line no-unused-vars function loadPkdx(){ - let playerRegion = player.highestRegion(); - let pkdxBody = document.querySelector(':scope #pkdx tbody'); - pkdxBody.innerHTML = ''; - let toAdd = ""; - for (const pokemon of pokemonList) { - if ((pokemon.nativeRegion <= playerRegion && pokemon.nativeRegion > -1) || (pokemon.nativeRegion == -1 && playerRegion >= GameConstants.Region.alola) || pokemon.id == 0) { - let lpkm = App.game.party.getPokemon(pokemon.id); - let region = GameConstants.Region[pokemon.nativeRegion].charAt(0).toUpperCase() + GameConstants.Region[pokemon.nativeRegion].slice(1); - let hint = ""; - let getPokemonLocation = PokemonLocations.getPokemonLocations(pokemon.name, playerRegion); - let roadLocations = getPokemonLocation[0] - if (roadLocations) { - for (let i = 0; i <= playerRegion; i++) { - const reg = GameConstants.Region[i]; - let roads = "Route" - roadLocations[i]?.forEach((route) => { - roads += ` ${route.route},` - }); - if (roads !== "Route") - hint += `${hint !== "" ? `\n` : ""}${reg.charAt(0).toUpperCase() + reg.slice(1)}: ${roads.slice(0, -1)}`; - } - if (hint !== "") - hint = ` title="${hint}"`; - } - toAdd += ` - - ${pokemon.id} - ${region} - - ${pokemon.name} - - - YES') : '194, 46, 40);">NO'} - - `; - } - } - pkdxBody.innerHTML = toAdd; - filterPkdx(); - pkdxLoadEventHandlers(); + let playerRegion = player.highestRegion(); + let pkdxBody = document.querySelector(':scope #pkdx tbody'); + pkdxBody.innerHTML = ''; + let toAdd = ""; + for (const pokemon of pokemonList) { + if ((pokemon.nativeRegion <= playerRegion && pokemon.nativeRegion > -1) || (pokemon.nativeRegion == -1 && playerRegion >= GameConstants.Region.alola) || pokemon.id == 0) { + let lpkm = App.game.party.getPokemon(pokemon.id); + let region = GameConstants.Region[pokemon.nativeRegion].charAt(0).toUpperCase() + GameConstants.Region[pokemon.nativeRegion].slice(1); + let hint = ""; + let getPokemonLocation = PokemonLocations.getPokemonLocations(pokemon.name, playerRegion); + let roadLocations = getPokemonLocation[0] + if (roadLocations) { + for (let i = 0; i <= playerRegion; i++) { + const reg = GameConstants.Region[i]; + let roads = "Route" + roadLocations[i]?.forEach((route) => { + roads += ` ${route.route},` + }); + if (roads !== "Route") + hint += `${hint !== "" ? `\n` : ""}${reg.charAt(0).toUpperCase() + reg.slice(1)}: ${roads.slice(0, -1)}`; + } + if (hint !== "") + hint = ` title="${hint}"`; + } + toAdd += ` + + ${pokemon.id} + ${region} + + ${pokemon.name} + + + YES') : '194, 46, 40);">NO'} + + `; + } + } + pkdxBody.innerHTML = toAdd; + filterPkdx(); + pkdxLoadEventHandlers(); } function loadQuestLines() { - let qlBody = document.querySelector(':scope #questlinelist tbody'); - qlBody.innerHTML = ''; - let toAdd = ""; - - for (const ql of App.game.quests.questLines()) { - let state = QuestLineState[ql.state()] - state = state.charAt(0).toUpperCase() + state.slice(1) - - let stateColor; - switch (ql.state()) { - case 0: - stateColor = "244, 80, 80"; - break; - case 1: - stateColor = "99, 144, 240"; - break; - case 2: - stateColor = "122, 199, 76"; - break; - } - - toAdd += ` - - ${ql.name} - ${state} - - `; - } - - // App.game.quests.questLines().filter(e => e.state() < 2).forEach(e => console.log(e.name, e.state())) - - qlBody.innerHTML = toAdd; - filterQuestLine(); + let qlBody = document.querySelector(':scope #questlinelist tbody'); + qlBody.innerHTML = ''; + let toAdd = ""; + + for (const ql of App.game.quests.questLines()) { + let state = QuestLineState[ql.state()] + state = state.charAt(0).toUpperCase() + state.slice(1) + + let stateColor; + switch (ql.state()) { + case 0: + stateColor = "244, 80, 80"; + break; + case 1: + stateColor = "99, 144, 240"; + break; + case 2: + stateColor = "122, 199, 76"; + break; + } + + toAdd += ` + + ${ql.name} + ${state} + + `; + } + + // App.game.quests.questLines().filter(e => e.state() < 2).forEach(e => console.log(e.name, e.state())) + + qlBody.innerHTML = toAdd; + filterQuestLine(); } function loadEventHandlers() { - // currency - for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { - document.getElementById("currency_" + i).addEventListener("click", gainCurrency); - } - - // gems - for (let i = 0; i < Gems.nTypes; i++) { - document.getElementById("gems_" + i).addEventListener("click", function () { - App.game.gems.gainGems(parseInt(document.getElementById('inputAddGems').value || 0), i); - }); - } - - // pokeballs - for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { - document.getElementById("pokeballs_" + i).addEventListener("click", function () { - App.game.pokeballs.gainPokeballs(i, parseInt(document.getElementById('inputAddPokeballs').value || 0), true); - }); - } - - // berries - for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { - document.getElementById("berries_" + i).addEventListener("click", function () { - App.game.farming.gainBerry(i, parseInt(document.getElementById('inputAddBerries').value || 0), true); - }); - } - - // evolution items - for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { - document.getElementById("evolutionitems_" + i).addEventListener("click", function () { - player.gainItem(this.getAttribute("item"), parseInt(document.getElementById('inputAddEvolutionItems').value || 0), true); - }); - } - - // vitamins - for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { - document.getElementById("vitamins_" + i).addEventListener("click", function () { - player.gainItem(this.getAttribute("vitamin"), parseInt(document.getElementById('inputAddVitamins').value || 0), true); - }); - } - - // held items - HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { - document.getElementById("attackhelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().attack.items[idk].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { - document.getElementById("typehelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().typeRestricted.items[idx].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { - document.getElementById("evhelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().ev.items[idx].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { - document.getElementById("exphelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().exp.items[idx].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { - document.getElementById("otherhelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().other.items[idx].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); - }); - }); - - // pokedex - document.getElementById("pokedex").children[1].addEventListener("click", loadPkdx); - document.getElementById("pkdxNameFilter").addEventListener("input", filterPkdx); - document.getElementById("pkdxRegionFilter").addEventListener("change", filterPkdx); - document.getElementById("pkdxShinyFilter").addEventListener("change", filterPkdx); - document.getElementById("pkdxPKRSFilter").addEventListener("change", filterPkdx); - - // questline - document.getElementById("questlines").children[1].addEventListener("click", loadQuestLines); - document.getElementById("questLineFilter").addEventListener("change", filterQuestLine); + // currency + for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { + document.getElementById("currency_" + i).addEventListener("click", gainCurrency); + } + + // gems + for (let i = 0; i < Gems.nTypes; i++) { + document.getElementById("gems_" + i).addEventListener("click", function () { + App.game.gems.gainGems(parseInt(document.getElementById('inputAddGems').value || 0), i); + }); + } + + // pokeballs + for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { + document.getElementById("pokeballs_" + i).addEventListener("click", function () { + App.game.pokeballs.gainPokeballs(i, parseInt(document.getElementById('inputAddPokeballs').value || 0), true); + }); + } + + // berries + for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { + document.getElementById("berries_" + i).addEventListener("click", function () { + App.game.farming.gainBerry(i, parseInt(document.getElementById('inputAddBerries').value || 0), true); + }); + } + + // evolution items + for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { + document.getElementById("evolutionitems_" + i).addEventListener("click", function () { + player.gainItem(this.getAttribute("item"), parseInt(document.getElementById('inputAddEvolutionItems').value || 0), true); + }); + } + + // vitamins + for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { + document.getElementById("vitamins_" + i).addEventListener("click", function () { + player.gainItem(this.getAttribute("vitamin"), parseInt(document.getElementById('inputAddVitamins').value || 0), true); + }); + } + + // held items + HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { + document.getElementById("attackhelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().attack.items[idk].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { + document.getElementById("typehelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().typeRestricted.items[idx].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { + document.getElementById("evhelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().ev.items[idx].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { + document.getElementById("exphelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().exp.items[idx].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { + document.getElementById("otherhelditems_" + idx).addEventListener("click", function () { + HeldItem.getSortedHeldItems().other.items[idx].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + }); + }); + + // pokedex + document.getElementById("pokedex").children[1].addEventListener("click", loadPkdx); + document.getElementById("pkdxNameFilter").addEventListener("input", filterPkdx); + document.getElementById("pkdxRegionFilter").addEventListener("change", filterPkdx); + document.getElementById("pkdxShinyFilter").addEventListener("change", filterPkdx); + document.getElementById("pkdxPKRSFilter").addEventListener("change", filterPkdx); + + // questline + document.getElementById("questlines").children[1].addEventListener("click", loadQuestLines); + document.getElementById("questLineFilter").addEventListener("change", filterQuestLine); } function pkdxLoadEventHandlers() { - for (const pokemon of pokemonList) { - let pkElement = document.getElementById("pkdx_" + pokemon.id.toString().replace('.','_')); - if (pkElement){ - pkElement.children[4].addEventListener("click", gainPk); - pkElement.children[5].addEventListener("click", gainPkrs); - } - } + for (const pokemon of pokemonList) { + let pkElement = document.getElementById("pkdx_" + pokemon.id.toString().replace('.','_')); + if (pkElement){ + pkElement.children[4].addEventListener("click", gainPk); + pkElement.children[5].addEventListener("click", gainPkrs); + } + } } function initSaveEditor() { - // Add menu item - let eventLi = document.createElement('li'); - eventLi.innerHTML = `Debug Cheats` - profileDrop.before(eventLi); - - // Add popup - let eventMod = document.createElement('div'); - eventMod.setAttribute("class", "modal noselect fade show"); - eventMod.setAttribute("id", "saveEditorModal"); - eventMod.setAttribute("tabindex", "-1"); - eventMod.setAttribute("aria-labelledby", "saveEditorModal"); - eventMod.setAttribute("aria-modal", "true"); - eventMod.setAttribute("role", "dialog"); - - eventMod.innerHTML = ` - - `; - - profileModal.before(eventMod); - - let modalBody = document.querySelector('[id=saveEditorModal] div div [class=modal-body]'); - - // currency - for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { - const itm = GameConstants.Currency[i]; - const itmPretty = itm.charAt(0).toUpperCase() + itm.replace(/[A-Z]/g, ' $&').trim().slice(1); - modalBody.querySelector('#currency').innerHTML += ` -
- -
${itmPretty}
-
- `; - } - - // gems - for (let i = 0; i < Gems.nTypes; i++) { - const itm = PokemonType[i]; - modalBody.querySelector('#gems').innerHTML += ` -
- -
${itm}
-
- `; - } - - // pokeballs - for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { - const itm = GameConstants.Pokeball[i]; - modalBody.querySelector('#pokeballs').innerHTML += ` -
- -
${itm}
-
- `; - } - - // berries - for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { - const itm = BerryType[i]; - modalBody.querySelector('#berries').innerHTML += ` -
- -
${itm}
-
- `; - } - - // evolution items - for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { - const itm = GameConstants.StoneType[i]; - const itmPretty = itm.replaceAll('_', ' ').replace(/\b\w/g, function(char) { - return char.toUpperCase(); - }); - modalBody.querySelector('#evolutionItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - } - - // vitamins - for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { - const itm = GameConstants.VitaminType[i]; - modalBody.querySelector('#vitamins').innerHTML += ` -
- -
${itm}
-
- `; - } - - // held items - HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { - const itmPretty = itm.name.replaceAll('_', ' '); - modalBody.querySelector('#heldItems').innerHTML += ` -
- -
${itmPretty}
-
- `; - }); - - // pokedex - const pkdxRegFilt = modalBody.querySelector('#pkdxRegionFilter'); - for (let i = 0; i <= player.highestRegion(); i++) { - const reg = GameConstants.Region[i] - pkdxRegFilt.innerHTML += ``; - } - pkdxRegFilt.innerHTML += ''; - - - loadEventHandlers(); + // Add menu item + let eventLi = document.createElement('li'); + eventLi.innerHTML = `Debug Cheats` + profileDrop.before(eventLi); + + // Add popup + let eventMod = document.createElement('div'); + eventMod.setAttribute("class", "modal noselect fade show"); + eventMod.setAttribute("id", "saveEditorModal"); + eventMod.setAttribute("tabindex", "-1"); + eventMod.setAttribute("aria-labelledby", "saveEditorModal"); + eventMod.setAttribute("aria-modal", "true"); + eventMod.setAttribute("role", "dialog"); + + eventMod.innerHTML = ` + + `; + + profileModal.before(eventMod); + + let modalBody = document.querySelector('[id=saveEditorModal] div div [class=modal-body]'); + + // currency + for (let i = 0; i < Object.keys(GameConstants.Currency).filter(isNaN).length; i++) { + const itm = GameConstants.Currency[i]; + const itmPretty = itm.charAt(0).toUpperCase() + itm.replace(/[A-Z]/g, ' $&').trim().slice(1); + modalBody.querySelector('#currency').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + } + + // gems + for (let i = 0; i < Gems.nTypes; i++) { + const itm = PokemonType[i]; + modalBody.querySelector('#gems').innerHTML += ` +
+ +
${itm}
+
+ `; + } + + // pokeballs + for (let i = 0; i < Object.keys(GameConstants.Pokeball).filter(isNaN).length - 1; i++) { + const itm = GameConstants.Pokeball[i]; + modalBody.querySelector('#pokeballs').innerHTML += ` +
+ +
${itm}
+
+ `; + } + + // berries + for (let i = 0; i < Object.keys(BerryType).filter(isNaN).length - 1; i++) { + const itm = BerryType[i]; + modalBody.querySelector('#berries').innerHTML += ` +
+ +
${itm}
+
+ `; + } + + // evolution items + for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { + const itm = GameConstants.StoneType[i]; + const itmPretty = itm.replaceAll('_', ' ').replace(/\b\w/g, function(char) { + return char.toUpperCase(); + }); + modalBody.querySelector('#evolutionItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + } + + // vitamins + for (let i = 0; i < Object.keys(GameConstants.VitaminType).filter(isNaN).length; i++) { + const itm = GameConstants.VitaminType[i]; + modalBody.querySelector('#vitamins').innerHTML += ` +
+ +
${itm}
+
+ `; + } + + // held items + HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => { + const itmPretty = itm.name.replaceAll('_', ' '); + modalBody.querySelector('#heldItems').innerHTML += ` +
+ +
${itmPretty}
+
+ `; + }); + + // pokedex + const pkdxRegFilt = modalBody.querySelector('#pkdxRegionFilter'); + for (let i = 0; i <= player.highestRegion(); i++) { + const reg = GameConstants.Region[i] + pkdxRegFilt.innerHTML += ``; + } + pkdxRegFilt.innerHTML += ''; + + + loadEventHandlers(); } /* WIP, sevii helper var lst = pokemonList.filter((p) => p.name.includes('Pinkan') - || p.name.includes('Valencian') - || p.name === 'Crystal Onix' - || p.name === 'Ash\'s Butterfree' - || p.name === 'Pink Butterfree'); + || p.name.includes('Valencian') + || p.name === 'Crystal Onix' + || p.name === 'Ash\'s Butterfree' + || p.name === 'Pink Butterfree'); var caught = App.game.party.caughtPokemon - .filter((p) => p.name.includes('Pinkan') - || p.name.includes('Valencian') - || p.name === 'Crystal Onix' - || p.name === 'Ash\'s Butterfree' - || p.name === 'Pink Butterfree'); + .filter((p) => p.name.includes('Pinkan') + || p.name.includes('Valencian') + || p.name === 'Crystal Onix' + || p.name === 'Ash\'s Butterfree' + || p.name === 'Pink Butterfree'); var caughtNames = caught.map(e => e.name); var missing = lst.filter(e => !caughtNames.includes(e.name)); @@ -620,71 +620,71 @@ console.log(missing); */ function loadEpheniaScript(scriptName, initFunction, priorityFunction) { - function reportScriptError(scriptName, error) { - console.error(`Error while initializing '${scriptName}' userscript:\n${error}`); - Notifier.notify({ - type: NotificationConstants.NotificationOption.warning, - title: scriptName, - message: `The '${scriptName}' userscript crashed while loading. Check for updates or disable the script, then restart the game.\n\nReport script issues to the script developer, not to the Pokéclicker team.`, - timeout: GameConstants.DAY, - }); - } - const windowObject = !App.isUsingClient ? unsafeWindow : window; - // Inject handlers if they don't exist yet - if (windowObject.epheniaScriptInitializers === undefined) { - windowObject.epheniaScriptInitializers = {}; - const oldInit = Preload.hideSplashScreen; - var hasInitialized = false; - - // Initializes scripts once enough of the game has loaded - Preload.hideSplashScreen = function (...args) { - var result = oldInit.apply(this, args); - if (App.game && !hasInitialized) { - // Initialize all attached userscripts - Object.entries(windowObject.epheniaScriptInitializers).forEach(([scriptName, initFunction]) => { - try { - initFunction(); - } catch (e) { - reportScriptError(scriptName, e); - } - }); - hasInitialized = true; - } - return result; - } - } - - // Prevent issues with duplicate script names - if (windowObject.epheniaScriptInitializers[scriptName] !== undefined) { - console.warn(`Duplicate '${scriptName}' userscripts found!`); - Notifier.notify({ - type: NotificationConstants.NotificationOption.warning, - title: scriptName, - message: `Duplicate '${scriptName}' userscripts detected. This could cause unpredictable behavior and is not recommended.`, - timeout: GameConstants.DAY, - }); - let number = 2; - while (windowObject.epheniaScriptInitializers[`${scriptName} ${number}`] !== undefined) { - number++; - } - scriptName = `${scriptName} ${number}`; - } - // Add initializer for this particular script - windowObject.epheniaScriptInitializers[scriptName] = initFunction; - // Run any functions that need to execute before the game starts - if (priorityFunction) { - $(document).ready(() => { - try { - priorityFunction(); - } catch (e) { - reportScriptError(scriptName, e); - // Remove main initialization function - windowObject.epheniaScriptInitializers[scriptName] = () => null; - } - }); - } + function reportScriptError(scriptName, error) { + console.error(`Error while initializing '${scriptName}' userscript:\n${error}`); + Notifier.notify({ + type: NotificationConstants.NotificationOption.warning, + title: scriptName, + message: `The '${scriptName}' userscript crashed while loading. Check for updates or disable the script, then restart the game.\n\nReport script issues to the script developer, not to the Pokéclicker team.`, + timeout: GameConstants.DAY, + }); + } + const windowObject = !App.isUsingClient ? unsafeWindow : window; + // Inject handlers if they don't exist yet + if (windowObject.epheniaScriptInitializers === undefined) { + windowObject.epheniaScriptInitializers = {}; + const oldInit = Preload.hideSplashScreen; + var hasInitialized = false; + + // Initializes scripts once enough of the game has loaded + Preload.hideSplashScreen = function (...args) { + var result = oldInit.apply(this, args); + if (App.game && !hasInitialized) { + // Initialize all attached userscripts + Object.entries(windowObject.epheniaScriptInitializers).forEach(([scriptName, initFunction]) => { + try { + initFunction(); + } catch (e) { + reportScriptError(scriptName, e); + } + }); + hasInitialized = true; + } + return result; + } + } + + // Prevent issues with duplicate script names + if (windowObject.epheniaScriptInitializers[scriptName] !== undefined) { + console.warn(`Duplicate '${scriptName}' userscripts found!`); + Notifier.notify({ + type: NotificationConstants.NotificationOption.warning, + title: scriptName, + message: `Duplicate '${scriptName}' userscripts detected. This could cause unpredictable behavior and is not recommended.`, + timeout: GameConstants.DAY, + }); + let number = 2; + while (windowObject.epheniaScriptInitializers[`${scriptName} ${number}`] !== undefined) { + number++; + } + scriptName = `${scriptName} ${number}`; + } + // Add initializer for this particular script + windowObject.epheniaScriptInitializers[scriptName] = initFunction; + // Run any functions that need to execute before the game starts + if (priorityFunction) { + $(document).ready(() => { + try { + priorityFunction(); + } catch (e) { + reportScriptError(scriptName, e); + // Remove main initialization function + windowObject.epheniaScriptInitializers[scriptName] = () => null; + } + }); + } } if (!App.isUsingClient || localStorage.getItem('debugcheatstools') === 'true') { - loadEpheniaScript('debugcheatstools', initSaveEditor); + loadEpheniaScript('debugcheatstools', initSaveEditor); } From c6272cec16231fb2d04b62685bfe35f3e3b0399d Mon Sep 17 00:00:00 2001 From: iamc24 <42425100+iamc24@users.noreply.github.com> Date: Wed, 30 Jul 2025 17:30:23 -0700 Subject: [PATCH 13/14] Update debugcheatstools.user.js Re-add custom html attribute accidentally removed when simplifying event handlers; Fix minor indentation issue --- custom/debugcheatstools.user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/custom/debugcheatstools.user.js b/custom/debugcheatstools.user.js index 602b5bb..0fd3e26 100644 --- a/custom/debugcheatstools.user.js +++ b/custom/debugcheatstools.user.js @@ -520,10 +520,10 @@ function initSaveEditor() { for (let i = 0; i < Object.keys(GameConstants.StoneType).filter(isNaN).length - 1; i++) { const itm = GameConstants.StoneType[i]; const itmPretty = itm.replaceAll('_', ' ').replace(/\b\w/g, function(char) { - return char.toUpperCase(); - }); + return char.toUpperCase(); + }); modalBody.querySelector('#evolutionItems').innerHTML += ` -
+
${itmPretty}
From 3a67a4513be7ab6712f58b1fa707868c4e032077 Mon Sep 17 00:00:00 2001 From: iamc24 <42425100+iamc24@users.noreply.github.com> Date: Wed, 30 Jul 2025 17:34:08 -0700 Subject: [PATCH 14/14] Update debugcheatstools.user.js Fix variable typo --- custom/debugcheatstools.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom/debugcheatstools.user.js b/custom/debugcheatstools.user.js index 0fd3e26..f2eaca3 100644 --- a/custom/debugcheatstools.user.js +++ b/custom/debugcheatstools.user.js @@ -276,7 +276,7 @@ function loadEventHandlers() { // held items HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => { document.getElementById("attackhelditems_" + idx).addEventListener("click", function () { - HeldItem.getSortedHeldItems().attack.items[idk].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); + HeldItem.getSortedHeldItems().attack.items[idx].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0)); }); }); HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => {