eileen12 / HaremHeroes Automatic

Now that the developers have broken the timers with a terrible update, does anyone have changes they use to make auto salary work again? Auto pachinko might be messed up as well since it is based on a timer. Salary is the most useful part of the script for me and now I have to either pause the script or open up a new tab to continue playing the game without the script continually setting the next salary time to zero seconds.

Anyone have a working solution for this breaking change?

The timers aren't actually broken they just show up differently now. For the past few hours I have been trying to figure it out to avail. Even my mission script is all messed up because of this. Auto pachinko in the script is based off a 24 hour timer that is not related to the page itself.

The only way I can think of to make this work again is to get the text from the span then convert that into a number based on h m s meaning it would have to recheck the time every time either the hours or minutes vanish. The seconds would obviously always be there but you won't see that until the minutes disappear.

If I could just get the span class to print to the console I should be able to make the rest of it work.

You're right. I should say that the display for them is different and that the change broke the scripts. I've been working on it as well but I am a bit rusty with javascript. So I've been having issues pulling the relevant data before setting the number of seconds in the cookies.

In eileen's script there are calls like

var energyCurrent = Number($("span[hero='energy_quest']").text());

and

Number($("div[hero='soft_currency'] span").text()

which might be helpful in pulling the spans.

Oops, I've messed up the code snippets in my post above but they are still pretty legible. I can't edit the post

Here is a temp fix it waits until you have over 10000 before collecting.

if (sessionStorage.autoSalary === "true" && busy === false) {
        var collect = ($('#collect_all').text().replace(/\s/g, ""));
        if  (collect.length >= 18){
            console.log("Time to fetch salary.");
            getSalary();
            busy = true;
        }
        else{
            busy = false;
        }
    }

Until I can figure out something better this is the best I can do.

Re: @Marti:
Thanks! Appreciate the fix for me. I'll be sure to make use of the preview button in the future.

Re: @3jameo3:
Nice! Looks good. I'll continue taking a look to see if I can find a fix as well but this fix seems really good regardless. I'll have to try to make use of it later today.

Re: @twelve27:

I forgot to mention you may have to remove all the occurrences of nextSalaryTime=; and the lines that go with it. Well at least that is what I did to make it work smoothly.

Re: @3jameo3:
Thanks. Now that I have some free time I'll be trying to see if I can work something, if anything, out with the changes.

Re: @twelve27:

This works unless it sees minutes so let me know if you figure out what I did wrong (no sleep coding doesn't work well). This is reverting back to eileen12's original code just updating the timer.

if (sessionStorage.autoSalary === "true" && busy === false) {
        if (Cookies.get("nextSalaryTime") === undefined) {
            console.log("Time to fetch salary.");
            getSalary();
            busy = true;
        }
        else if (Cookies.get("nextSalaryTime") === "") {
            console.log("Salary fetched. Getting next fetch time");
            if ($("nav div[rel='content'] a:has(.home)").attr("href") !== window.location.pathname) {
                console.log("Moving to home.");
                sessionStorage.autoLoop = "false";
                // Goto Home page.
                window.location = window.location.origin + $("nav div[rel='content'] a:has(.home)").attr("href");
                busy=true;
                return;
            }
            var CAB = $("#collect_all_bar .in").text();
            console.log(CAB)
            if (CAB.includes('h') && CAB.includes('m')) {
                CAB.replace('h','').replace('m','')
                var closestTime = Number(CAB[0] * 3600) + (Number(CAB[1] + CAB[2]) * 60)
            }
            if (CAB.includes('m')) { // <- Problem area either returns NaN or undefined when called
                CAB.replace('m','')
                var closestTime = Number(CAB) * 60
            }
            if (CAB.includes('s')) {
                CAB.replace('s','')
                var closestTime = Number(CAB)
            }
            document.cookie = "nextSalaryTime=present;max-age=" + (closestTime < 0 ? 0 : closestTime);
            console.log("New fetch time stored in nextSalaryTime cookie.(+" + closestTime + " sec.)");
            busy = false;
        }
    }

Re: @twelve27:

It bugged me so I spent more time on it and fixed it.

if (sessionStorage.autoSalary === "true" && busy === false) {
        if (Cookies.get("nextSalaryTime") === undefined) {
            console.log("Time to fetch salary.");
            getSalary();
            busy = true;
        }
        else if (Cookies.get("nextSalaryTime") === "") {
            console.log("Salary fetched. Getting next fetch time");
            if ($("nav div[rel='content'] a:has(.home)").attr("href") !== window.location.pathname) {
                console.log("Moving to home.");
                sessionStorage.autoLoop = "false";
                // Goto Home page.
                window.location = window.location.origin + $("nav div[rel='content'] a:has(.home)").attr("href");
                busy=true;
                return;
            }
            var CAB = $("#collect_all_bar .in").text();
            //console.log(CAB)
            if (CAB.includes('h') && CAB.includes('m')) {
                CAB.replace('h','').replace('m','')
                //console.log('"'+CAB+'"')
                var closestTime = Number(CAB[0] * 3600) + (Number(CAB[1] + CAB[2]) * 60)
                //console.log('"'+closestTime+'"')
            }
            if (CAB.includes('m')) {
                CAB.replace('m','')
                //console.log('"'+CAB+'"')
                var closestTime = Number(CAB.replace('m','')) * 60
                //console.log('"'+closestTime+'"')
            }
            if (CAB.includes('s')) {
                CAB.replace('s','')
                //console.log('"'+CAB+'"')
                var closestTime = Number(CAB.replace('s',''))
                //console.log('"'+closestTime+'"')
            }
            document.cookie = "nextSalaryTime=present;max-age=" + (closestTime < 0 ? 0 : closestTime);
            console.log("New fetch time stored in nextSalaryTime cookie.(+" + closestTime + " sec.)");
            busy = false;
        }
    }

After about 3-4 hours the above code had a hiccup and threw an undefined at me. I am guessing that multiple fetches tried to happen at one time which caused the error. Not exactly sure how this happened yet.

Re: @3jameo3:

Nice going, 3jame03! I've been trying to do some jQuery to try and find a working solution that requires as little change to eileen12's code as possible but haven't found anything truly viable so far.

Re: @twelve27:

Post if you find anything interesting to make things run smoothly. I just went through and added missing odds and ends in both of the scripts I have up (Auto Missions and Auto Salary). The salary script is a bit finicky it likes to be enabled first only from what I have seen so far.

Re: @3jameo3:
Sure, I'll let you know if I come up with anything that will be helpful. I'm actually trying to insert your auto salary script in now with what I have to see if it will work. Its not reacting for me so far so I'll have to debug for now.

Re: @twelve27:

I did mess up in it so if you dont have the one i just posted remove the isnans in the salary portions. You can now also check out the script that I have been using myself for the entire site. Also clear your cookies etc if it doesnt fix.

Re: @3jameo3:
Yeah, I removed that portion with isNan. What I was actually looking at right now is that the script randomly stopped and next salary time was undefined. Clearing cookies solved the problem but temporarily. But I'll just start testing the other script you have for the entire site and see if the error reproduces itself.

Good work, again. Makes me want to brush up on my javascript skills way more. Maybe I'll see if I can add other features over time

Re: @twelve27:

I have the same issue reason I have the first code I posted as a fail-safe inside the script. I am not sure what exactly is going on with the script.

I want to add a way to select which bosses the autobattle chooses. And also to fix the problems ive been having with autoquesting.

Re: @3jameo3:

Not sure either but if I figure it out then I will let you know.

Select autobattle is a good idea since I don't want to fight the very last troll at the moment.

What is wrong with auto questing? I can't test it right now because I have no more quests available at the moment.

Re: @twelve27:

Sounds good.

It hangs up on the item and battle buttons as well as the end quest button. I haven't looked into the reason yet though.

Re: @3jameo3:
Next time I have a quest available I'll try to look at it as well.

For now, it seems what CAB is being set to returns nothing.

We could check the the length of CAB is 0 or if it does not include h, m, or s and take a certain action for there. I'm just not sure why that span becomes empty after a while. Maybe we'll have to navigate to check the harem page for the value

Re: @twelve27:

It should return nothing if the collect button is visible only. Which CAB is it that is returning nothing though where I have it splitting up it should be easy to tell.