Are you sure you want to go to an external site to donate a monetary value?
WARNING: Some countries laws may supersede the payment processors policy such as the GDPR and PayPal. While it is highly appreciated to donate, please check with your countries privacy and identity laws regarding privacy of information first. Use at your utmost discretion.
May have to change any of these that have a popup associated with them to true though.
sessionStorage.autoLoop = "false";
I am still testing things but I may have found a lead just now. If my assumption is correct then all the problems caused by popups may be fixed with this. Will keep everyone posted on the results.
If anyone wants to test with me add this to autoLoop() above pachinko so it always runs first ::
if(document.getElementById("popups").style.display === "block") { console.log("Popup detetcted. Refresh page."); unsafeWindow.reload(); return; }
Then remove the popup code from arena.
Re: @eileen12:
This problem for sure still exists it's acting as if the script isn't recognizing the button when it appears if the site lags.
Re: @twelve27:
Well it is still possible to change the countdown code back to the original which still works. May not be an elegant solution but at least it does work.
I have a forked version of this script on my page with 99% of the errors and warnings taken care of so that may help in the debugging process a bit. Also have one with the addition of a working Koban Pachinko if that peaks your fancy.
So I checked my logs as the free sign was still up and sure enough still have that undefined error. Even if all the warnings/errors that I found and fixed were part of the main problem it didn't solve the root of the problem.
Re: @Marti:
The flow of the FAQ was greatly improved. Maybe it would be possible to make an application for the -diff, I might try my hand in creating a python code to compare 2 different codes in the future.
Intervene anytime in my posts as I always learn about new things when you do, so thank you for that.
Re: @gobub:
Have you made sure you are using the latest version? Mine hasn't had an infinite loop since Eileen12 fixed the problem which also would sometimes have that address in previous versions.
Re: @Marti:
Sounds like a good amount of interesting updates to the site will be coming.
I look forward to that as I have little to no Linux knowledge.
Thank you for all of your help once again, the change to -diff really does make a huge difference.
Forked v3.22 with the code beautified and 99% error free
Re: @Marti:
Thank you for the information. I don't understand the code change part of the FAQ but I will use the fork method from now on.
Lines 258 and 295 were the lines with the redundant nested block aka {}. The only warnings remaining is resulting from the $ and Cookies portions of the code and the ES6 line of code ([...map]). I hope all of the time spent going through and fixing things that may or may not have been needed to be fixed helps in some way.
Re: @twelve27:
Today it didn't work for me until I cleaned my cookies and then refreshed the page. I am hoping that it is fixed. Though to be honest I am running the script that has no errors in it at all at the current time, so I wouldn't know if it was the latest update or all of the errors and warnings that I fixed.
Maybe one of the bug fixes has fixed this issue will know more in at least 19 hours maybe a few days.
Ignore the hardCurrency var in autoLoop I am currently trying to make a script for the payed version of pachinko which is actually finished just waiting on the kobans to hit 90 for it to be tested.
Missed some errors. Which may be the entire cause of the pachinko, as well as others?, problem(s).
for(var e in unsafeWindow.HHTimers.timersListMin){ if(unsafeWindow.HHTimers.timersListMin[e].$elm.selector.startsWith(".pachinko_change")) npach=unsafeWindow.HHTimers.timersListMin[e].remainingTime; }
to
for(var e in unsafeWindow.HHTimers.timersListMin){ if(unsafeWindow.HHTimers.timersListMin[e].$elm.selector.startsWith(".pachinko_change")) { npach=unsafeWindow.HHTimers.timersListMin[e].remainingTime; } }
for(var e in unsafeWindow.HHTimers.timers){ if(unsafeWindow.HHTimers.timers[e].$elm.selector.startsWith(".arena_refresh_counter")) arenatime=unsafeWindow.HHTimers.timers[e]; }
to
for(var e in unsafeWindow.HHTimers.timers){ if(unsafeWindow.HHTimers.timers[e].$elm.selector.startsWith(".arena_refresh_counter")) { arenatime=unsafeWindow.HHTimers.timers[e]; } }
for(e in unsafeWindow.HHTimers.timers){ if(unsafeWindow.HHTimers.timers[e].$elm[0].className.includes("contest_timer")) // get closest time if(!(unsafeWindow.HHTimers.timers[e].remainingTime>time)) time=unsafeWindow.HHTimers.timers[e].remainingTime; }
to
for(e in unsafeWindow.HHTimers.timers){ if(unsafeWindow.HHTimers.timers[e].$elm[0].className.includes("contest_timer")) { // get closest time if(!(unsafeWindow.HHTimers.timers[e].remainingTime>time)) { time=unsafeWindow.HHTimers.timers[e].remainingTime; } } }
for(var e in unsafeWindow.HHTimers.timers){ if(unsafeWindow.HHTimers.timers[e].$elm.selector.includes(".contest_timer")) time=unsafeWindow.HHTimers.timers[e]; }
to
for(var e in unsafeWindow.HHTimers.timers){ if(unsafeWindow.HHTimers.timers[e].$elm.selector.includes(".contest_timer")) { time=unsafeWindow.HHTimers.timers[e]; } }
for(e in unsafeWindow.HHTimers.timers){ if(unsafeWindow.HHTimers.timers[e].$elm.selector.includes(".after_gift")) time=unsafeWindow.HHTimers.timers[e]; }
to
for(e in unsafeWindow.HHTimers.timers){ if(unsafeWindow.HHTimers.timers[e].$elm.selector.includes(".after_gift")) { time=unsafeWindow.HHTimers.timers[e]; } }
for(var e in unsafeWindow.HHTimers.timers){ if(unsafeWindow.HHTimers.timers[e].$elm.selector.includes("#missions_counter")) time=unsafeWindow.HHTimers.timers[e]; }
to
for(var e in unsafeWindow.HHTimers.timers){ if(unsafeWindow.HHTimers.timers[e].$elm.selector.includes("#missions_counter")) { time=unsafeWindow.HHTimers.timers[e]; } }
There is also a redundant nested block. So after all of this the code now looks like ::
EDITED by OUJS Admin
--- b.user.js 2018-07-17 00:06:33.351884738 -0600 +++ c.user.js 2018-07-17 00:20:39.757760066 -0600 @@ -283,7 +283,7 @@ data.missionObject = missionObject; var rewards = []; // set rewards - { + // get Reward slots var slots = missionObject.querySelectorAll(".slot"); // traverse slots @@ -322,7 +322,7 @@ } rewards.push(reward); }); - } + data.rewards = rewards; missions.push(data); }); @@ -369,7 +369,9 @@ var time = 0; for(var e in unsafeWindow.HHTimers.timers){ if(unsafeWindow.HHTimers.timers[e].$elm.selector.includes("#missions_counter")) + { time=unsafeWindow.HHTimers.timers[e]; + } } time = time.remainingTime; if(time === undefined) @@ -377,7 +379,9 @@ //try again with different selector for(e in unsafeWindow.HHTimers.timers){ if(unsafeWindow.HHTimers.timers[e].$elm.selector.includes(".after_gift")) + { time=unsafeWindow.HHTimers.timers[e]; + } } time = time.remainingTime; } @@ -411,7 +415,9 @@ var time = 0; for(var e in unsafeWindow.HHTimers.timers){ if(unsafeWindow.HHTimers.timers[e].$elm.selector.includes(".contest_timer")) + { time=unsafeWindow.HHTimers.timers[e]; + } } time = time.remainingTime; if(time === undefined) @@ -420,9 +426,13 @@ time = undefined; for(e in unsafeWindow.HHTimers.timers){ if(unsafeWindow.HHTimers.timers[e].$elm[0].className.includes("contest_timer")) + { // get closest time if(!(unsafeWindow.HHTimers.timers[e].remainingTime>time)) + { time=unsafeWindow.HHTimers.timers[e].remainingTime; + } + } } } if(time === undefined){ @@ -590,7 +600,9 @@ var arenatime = 0; for(var e in unsafeWindow.HHTimers.timers){ if(unsafeWindow.HHTimers.timers[e].$elm.selector.startsWith(".arena_refresh_counter")) + { arenatime=unsafeWindow.HHTimers.timers[e]; + } } arenatime = arenatime.remainingTime; Cookies.set('nextArenaTime',arenatime,{expires:new Date(new Date().getTime() + arenatime * 1000)}); @@ -699,7 +711,9 @@ var npach; for(var e in unsafeWindow.HHTimers.timersListMin){ if(unsafeWindow.HHTimers.timersListMin[e].$elm.selector.startsWith(".pachinko_change")) + { npach=unsafeWindow.HHTimers.timersListMin[e].remainingTime; + } } if(npach !== undefined || npach !== 0) { @@ -722,6 +736,7 @@ var busy = false; var page = window.location.href; var currentPower = getHero().infos.energy_fight; + var hardCurrency = getHero().infos.hard_currency; //console.log("sal="+sessionStorage.autoSalary); if(sessionStorage.autoFreePachinko === "true" && busy === false){ // Navigate to pachinko
There may or may not be changes in there that are not actually needed. Personally I have no idea I was just going through and correcting as many warnings and errors that I could find.
Full script free from errors (minus the ones that pop up for $ and the like) and end_play button fixed, as I noticed that the button when needing money or energy still didn't work at times.
EDITED By OUJS Admin
--- a.user.js 2018-07-17 00:05:16.215352417 -0600 +++ b.user.js 2018-07-17 00:06:33.351884738 -0600 @@ -20,7 +20,7 @@ { if(unsafeWindow.Hero === undefined) { - setTimeout(autoLoop, Number(sessionStorage.autoLoopTimeMili)) + setTimeout(autoLoop, Number(sessionStorage.autoLoopTimeMili)); //console.log(window.wrappedJSObject) } return unsafeWindow.Hero; @@ -43,7 +43,7 @@ } catch(err) { - return "" + return ""; } } @@ -57,7 +57,7 @@ else { console.log("Navigating to page: "+page); - var togoto = undefined; + var togoto; // get page path switch(page) { @@ -84,7 +84,7 @@ default: console.log("Unknown goto page request. No page \'"+page+"\' defined."); } - if(togoto != undefined) + if(togoto !== undefined) { sessionStorage.autoLoop = "false"; window.location = window.location.origin + togoto; @@ -108,6 +108,8 @@ var proceedCostEnergy = Number($("#controls .cost span[cur='*']").text()); var proceedCostMoney = Number($("#controls .cost span[cur='$']").text().trim().replace(',', '')); var proceedType = proceedButtonMatch.attr("act"); + var energyCurrent = getHero().infos.energy_quest; + var moneyCurrent = getHero().infos.soft_currency; if (proceedButtonMatch.length === 0) console.log("Could not find resume button."); else if (proceedType === "free") { @@ -115,8 +117,6 @@ proceedButtonMatch.click(); } else if (proceedType === "pay") { - var energyCurrent = getHero().infos.energy_quest; - var moneyCurrent = getHero().infos.soft_currency; if(proceedCostEnergy <= energyCurrent) { // We have energy. @@ -161,6 +161,28 @@ proceedButtonMatch.click(); } else if (proceedType === "end_play") { + if(proceedCostEnergy <= energyCurrent) + { + // We have energy. + console.log("Spending "+proceedCostEnergy+" Energy to proceed."); + } + else + { + console.log("Quest requires "+proceedCostEnergy+" Energy to proceed."); + sessionStorage.questRequirement = "*"+proceedCostEnergy; + return; + } + if(proceedCostMoney <= moneyCurrent) + { + // We have money. + console.log("Spending "+proceedCostMoney+" Money to proceed."); + } + else + { + console.log("Spending "+proceedCostEnergy+" Money to proceed."); + sessionStorage.questRequirement = "$"+proceedCostMoney; + return; + } console.log("Reached end of current play. Proceeding to next play."); sessionStorage.autoLoop = "false"; proceedButtonMatch.click(); @@ -430,7 +452,7 @@ }); console.log("Salary fetched. Getting next fetch time"); // In seconds - var closestTime = undefined; + var closestTime; var gMap = getGirlsMap(); if(gMap === undefined) { @@ -516,7 +538,7 @@ return; } var worldPage = worldMap.get(sessionStorage.trollToFight); - if(worldPage == undefined) + if(worldPage === undefined) { console.log("ERROR! worldPage undefined for troll at: "+sessionStorage.trollToFight); return; @@ -564,7 +586,7 @@ var selbutton = $(".opponents_arena .sub_block button:contains('Select')"); if(selbutton.length<1) { - console.log("No arena opponents found, storing nextArenaTime...") + console.log("No arena opponents found, storing nextArenaTime..."); var arenatime = 0; for(var e in unsafeWindow.HHTimers.timers){ if(unsafeWindow.HHTimers.timers[e].$elm.selector.startsWith(".arena_refresh_counter")) @@ -612,7 +634,7 @@ } return; } - console.log("battle price: "+battle_price+"P") + console.log("battle price: "+battle_price+"P"); if(currentPower >= battle_price) { // We have the power. @@ -682,6 +704,7 @@ if(npach !== undefined || npach !== 0) { Cookies.set('nextPachinkoTime',npach,{expires:new Date(new Date().getTime() + npach * 1000)}); + console.log('Next free pachinko in : ' + Cookies.get('nextPachinkoTime') + ' secs'); } else { @@ -909,18 +932,15 @@ } // Add UI buttons. var UIcontainer = $("#contains_all nav div[rel='content']"); - UIcontainer.html('<div style="position: absolute;right: 18.66%; padding: 10px;width: inherit;text-align: center;display:flex;flex-direction:column;">' - + '<span>AutoSal.</span><div><label class=\"switch\"><input id=\"autoSalaryCheckbox\" type=\"checkbox\"><span class=\"slider round\"></span></label></div>' - + '<span>AutoContest</span><div><label class=\"switch\"><input id=\"autoContestCheckbox\" type=\"checkbox\"><span class=\"slider round\"></span></label></div>' - + '<span>AutoMission</span><div><label class=\"switch\"><input id=\"autoMissionCheckbox\" type=\"checkbox\"><span class=\"slider round\"></span></label></div>' - +'<span>AutoQuest</span><div><label class=\"switch\"><input id=\"autoQuestCheckbox\" type=\"checkbox\"><span class=\"slider round\"></span></label></div>' - +'<span>AutoTrollBattle</span><div>\ - <label class=\"switch\"><input id=\"autoBattleCheckbox\" type=\"checkbox\"><span class=\"slider round\"></span></label>\ - <select id=\"autoTrollSelector\"><option value=\"latest\">Latest</option></select>\ - </div>' - +'<span>AutoArenaBattle</span><div><label class=\"switch\"><input id=\"autoArenaCheckbox\" type=\"checkbox\"><span class=\"slider round\"></span></label></div>' - +'<span>AutoPachinko(Free)</span><div><label class=\"switch\"><input id=\"autoFreePachinko\" type=\"checkbox\"><span class=\"slider round\"></span></label></div>' - +'</div>'+UIcontainer.html()); + UIcontainer.html('<div style="position: absolute;right: 18.66%; padding: 10px;width: inherit;text-align: center;display:flex;flex-direction:column;">'+ + '<span>AutoSal.</span><div><label class=\"switch\"><input id=\"autoSalaryCheckbox\" type=\"checkbox\"><span class=\"slider round\"></span></label></div>'+ + '<span>AutoContest</span><div><label class=\"switch\"><input id=\"autoContestCheckbox\" type=\"checkbox\"><span class=\"slider round\"></span></label></div>'+ + '<span>AutoMission</span><div><label class=\"switch\"><input id=\"autoMissionCheckbox\" type=\"checkbox\"><span class=\"slider round\"></span></label></div>'+ + '<span>AutoQuest</span><div><label class=\"switch\"><input id=\"autoQuestCheckbox\" type=\"checkbox\"><span class=\"slider round\"></span></label></div>'+ + '<span>AutoTrollBattle</span><div><label class=\"switch\"><input id=\"autoBattleCheckbox\" type=\"checkbox\"><span class=\"slider round\"></span></label><select id=\"autoTrollSelector\"><option value=\"latest\">Latest</option></select></div>'+ + '<span>AutoArenaBattle</span><div><label class=\"switch\"><input id=\"autoArenaCheckbox\" type=\"checkbox\"><span class=\"slider round\"></span></label></div>'+ + '<span>AutoPachinko(Free)</span><div><label class=\"switch\"><input id=\"autoFreePachinko\" type=\"checkbox\"><span class=\"slider round\"></span></label></div>'+ + '</div>'+UIcontainer.html()); // Add auto troll options var trollOptions = document.getElementById("autoTrollSelector"); globalWorldMap.forEach(function(val,key){
var closestTime = undefined;
to
var closestTime;
if(worldPage == undefined)
to
if(worldPage === undefined)
console.log("No arena opponents found, storing nextArenaTime...")
to
console.log("No arena opponents found, storing nextArenaTime...");
console.log("battle price: "+battle_price+"P")
to
console.log("battle price: "+battle_price+"P");
Found this site after finding those remaining errors. The configure option is really neat with all the different options. Considering this site doesn't do a full check this may help in future bug prevention.
setTimeout(autoLoop, Number(sessionStorage.autoLoopTimeMili))
to
setTimeout(autoLoop, Number(sessionStorage.autoLoopTimeMili));
return ""
to
return "";
var togoto = undefined;
to
var togoto;
if(togoto != undefined)
to
if(togoto !== undefined)
If I find more I will add to this topic. These may help fix some errors that may or may not ever show themselves but I thought I may as well point them out.
I have given this a lot of thought and I believe that the code after the button click is executing faster than the time until the next free pachinko is displayed resulting in the undefined errors. Reason being is if one were to clear cookies then refresh the page and re-enable AutoPachinko the time is no longer undefined. A sleep or timeout function may be needed or a way to close pachinko then re-open it before the timer code executes.
So far no errors funny how code placement can mean infinite loop or not :).
Nevermind, that still didn't fix the undefined error.
After tinkering with pachinko this code, so far, works.
var getPachinko = function(){ console.log(Cookies.get('nextPachinkoTime')); try { if(!gotoPage("pachinko")) { // Not at Pachinko screen then goto the Pachinko screen. console.log("Navigating to Pachinko window."); return; } else { console.log("Detected Pachinko Screen. Fetching Pachinko"); $("#pachinko button[free=1]")[0].click(); var npach; for(var e in unsafeWindow.HHTimers.timersListMin){ if(unsafeWindow.HHTimers.timersListMin[e].$elm.selector.startsWith(".pachinko_change")) npach=unsafeWindow.HHTimers.timersListMin[e].remainingTime; } if(npach !== undefined || npach !== 0) { Cookies.set('nextPachinkoTime',npach,{expires:new Date(new Date().getTime() + npach * 1000)}); console.log('Next free pachinko in : ' + Cookies.get('nextPachinkoTime') + ' secs') } else { Cookies.remove('nextPachinkoTime'); } } if (Cookies.get('nextPachinkoTime') === undefined) { console.log("Next free pachinko time was undefined... Setting it manually to 10min."); npach = 10*60; Cookies.set('nextPachinkoTime',npach,{expires:new Date(new Date().getTime() + npach * 1000)}); console.log('Next free pachinko in : ' + Cookies.get('nextPachinkoTime') + ' secs') } } catch (ex) { console.log("Could not collect pachinko... " + ex); } };
However I have no idea if it continues to collect pachinko until a few more days of testing, gotta love 24 hour wait times. I added a console.log as well just for visual confirmation of the remaining time.
Re: @eileen12:
Working properly for now still waiting to see if it works after AutoQuesting kicks in and changes the map, but from what I have witnessed so far I doubt it will be an issue.
Re: @eileen12:
While investigating further it seems as though once the troll map comes up the worldMap var becomes false thus resulting in the infinite loop. Which I am guessing that the worldMap var is not being stored anywhere to prevent that instead it is constantly being checked and then changed as the page changes.
Same issue with the rest of them.
Re: @eileen12:
Infinite loop not sure if its just gems kingdom though but the latest troll still works fine.