eileen12 / HaremHeroes Automatic

AutoPachinko seems to never return a 2nd, 3rd, etc time to collect the free pachinko.

Re: @eileen12:

VM365 userscript.html:858 Time to fetch Pachinko.
VM365 userscript.html:827 Detected Pachinko Screen. Fetching Pachinko
VM365 userscript.html:1014 Restoring page https://nutaku.haremheroes.com/home.html
VM360 phoenix-default-53138249.js:7644 error 
{class: "Pachinko", action: "play", what: "pachinko0", how_many: "1"}
 
Arguments(3) [{…}, "error", "", callee: ƒ, Symbol(Symbol.iterator): ƒ]

This is what happened to a new incognito window with the latest update. The bug we were talking about happened in the previous version. This bug occurred in the 3.2 update and did not collect pachinko as a result.

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.

Nevermind, that still didn't fix the undefined error.

VM144 userscript.html:895 Time to fetch Pachinko.
VM144 userscript.html:820 undefined
VM144 userscript.html:829 Detected Pachinko Screen. Fetching Pachinko
VM144 userscript.html:839 Next free pachinko in : undefined secs

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.

Maybe one of the bug fixes has fixed this issue will know more in at least 19 hours maybe a few days.

Re: @3jameo3:
Yes, it looks like it may be resolved right now. As of today when I had updated it worked fine. So I'll see tomorrow if it works or not.

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.

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.

Unfortunately I was away from my PC when a page crashed so I don't know if it would have worked normally for me. Guess I'll debug later if I have the time. Of course pachinko happens to be among the hardest to debug lol

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.