3jameo3 Author

Re: @Marti:

Thank you for the FAQ page it was an interesting read. Now I know how to change the highlighting if needed. Thank you for all of your help.

Re: @3jameo3:

So far the code that I posted above does work. However, the game still needs to change screens before it can grab a new mission or grab the time until the mission is completed.


Re: @Marti:

Actually the code button provided that. It didn't give 3 of the ' only 1 when it was used on the first line of the reply. If you could be so kind as to fix the highlighting problem that would appreciated as well as inform whoever is in charge of bugs about it I would appreciate it very much. I completely forgot to preview before posting a reply. Thank you in advance for the help.


if (sessionStorage.autoMissions === "true" && busy === false) {
        if (Cookies.get("nextActivityTime") === undefined && ($("#home_missions_bar1 .text").length) === 0 && ($("#home_missions_bar2 .text").length) <= 2 && ($("div[class='collect_notif']:not([style=''])"))) {
            console.log("Time to get a mission.");
            getMission();
            busy = true;
        }
        else if (Cookies.get("nextActivityTime") === "" && ($("#home_missions_bar1 .text").length) >= 0 && ($("#home_missions_bar2 .text").length) <= 2) {
            console.log("Accepting a mission. Getting countdown to next mission");
            if ($("nav div[rel='content'] a:has(.home)").attr("href") !== window.location.pathname) {
                console.log("Moving to home.");
                sessionStorage.autoLoop = "false";
                window.location = window.location.origin + $("nav div[rel='content'] a:has(.home)").attr("href");
                busy=true;
                return;
            }
            var MB1 = $("#home_missions_bar1 .text").text().replace('Complete in ','')
            //console.log(MB1)
            if (MB1.includes('h') && MB1.includes('m')) {
                var MB1 = $("#home_missions_bar1 .text").text().replace('Complete in ','').replace('h','').replace('m','').replace(' ','');
                //console.log('"'+MB1+'"')
                if (MB1.length == 1) {
                    var closestTime1 = Number((MB1[0]) * 3600);
                }
                if (MB1.length == 2) {
                    var closestTime1 = Number((MB1[0]) * 3600) + (Number(MB1[1]) * 60);
                }
                if (MB1.length == 3) {
                    var closestTime1 = Number((MB1[0]) * 3600) + (Number(MB1[1] + MB1[2]) * 60);
                }
                if (MB1.length == 4) {
                    var closestTime1 = Number((MB1[0] + MB1[1]) * 3600) + (Number(MB1[2] + MB1[3]) * 60);
                }
                //console.log('"'+closestTime1+'"')
                }
            if (MB1.includes('m')) {
                MB1.replace('m','')
                //console.log('"'+MB1+'"')
                var closestTime1 = Number(MB1.replace('m','')) * 60
                //console.log('"'+closestTime1+'"')
            }
            if (MB1.includes('s')) {
                MB1.replace('s','')
                //console.log('"'+MB1+'"')
                var closestTime1 = Number(MB1.replace('s',''))
                //console.log('"'+closestTime1+'"')
                }
            document.cookie = "nextActivityTime=present;max-age=" + (closestTime1 < 0 ? 0 : closestTime1);
            if (Cookies.get("nextActivityTime") === undefined && MB1.length >= 0) {
                getMission();
            }
            console.log("Time until next mission stored in nextActivityTime cookie.(+" + closestTime1 + " sec.)");
            busy = false;
        }
        if (Cookies.get("nextActivityTime") === "" && ($("#home_missions_bar1 .text").length) >= 0 && ($("#home_missions_bar2 .text").length) >= 0 && $("div[class='collect_notif']:not([style='display: none;'])")) {
            console.log("Time to collect the completed mission(s).");
            collectMission();
            busy = true;
        }
        if ((Cookies.get("nextActivityTime") === "" || Cookies.get("nextActivityTime") === undefined || Cookies.get("nextActivityTime") === 0) && ($("#home_missions_bar1 .text").length) <= 2 && ($("#home_missions_bar2 .text").length) >= 2) {
            console.log("All Missions Completed. Getting time until missions can be accepted again.");
            if ($("nav div[rel='content'] a:has(.home)").attr("href") !== window.location.pathname) {
                console.log("Moving to home.");
                sessionStorage.autoLoop = "false";
                window.location = window.location.origin + $("nav div[rel='content'] a:has(.home)").attr("href");
                busy=true;
                return;
            }
            var MB2 = $("#home_missions_bar2 .text").text().replace('Complete in ','');
            //console.log(MB2)
            if (MB2.includes('h') && MB2.includes('m')) {
                var MB2 = $("#home_missions_bar2 .text").text().replace('Complete in ','').replace('h','').replace('m','').replace(' ','');
                //console.log('"'+MB2+'"')
                if (MB2.length == 1) {
                    var closestTime1 = Number((MB2[0]) * 3600);
                }
                if (MB2.length == 2) {
                    var closestTime1 = Number((MB2[0]) * 3600) + (Number(MB2[1]) * 60);
                }
                if (MB2.length == 3) {
                    var closestTime1 = Number((MB2[0]) * 3600) + (Number(MB2[1] + MB2[2]) * 60);
                }
                if (MB2.length == 4) {
                    var closestTime1 = Number((MB2[0] + MB2[1]) * 3600) + (Number(MB2[2] + MB2[3]) * 60);
                }
                //console.log('"'+closestTime1+'"')
                }
            if (MB2.includes('m')) {
                MB2.replace('m','')
                //console.log('"'+MB2+'"')
                var closestTime1 = Number(MB2.replace('m','')) * 60
                //console.log('"'+closestTime1+'"')
            }
            if (MB2.includes('s')) {
                MB2.replace('s','')
                //console.log('"'+MB2+'"')
                var closestTime1 = Number(MB2.replace('s',''))
                //console.log('"'+closestTime1+'"')
                }
            document.cookie = "nextActivityTime=present;max-age=" + (closestTime1 < 0 ? 0 : closestTime1);
            console.log("Time until new missions stored in nextActivityTime cookie.(+" + closestTime1 + " sec.)");
            busy = false;
        }
    }```

Code I am currently testing atm, it is the previous version to what is in the current script with a couple edits.

Re: @twelve27:

Its not only the button mashing its constantly trying to loop through the claim mission section and when you edit that out it loops through the accept mission section. Debugging missions is a pain if they hadn't changed the timers then it would still be working but I digress.


Not exactly sure what is going on I am currently trying to debug it but it is a slow process.


Re: @twelve27:
I'm actually having issues with it lets talk on my page for the script considering it doesn't concern this one.


Re: @twelve27:

This is what I am running now its the same idea as yours just added more checks.

if ((CAB === undefined || CAB.length === 0) || (closestTime === undefined || closestTime === 0)) {
      closestTime = 5;
      getSalary();
      busy = true;
    }

The 5 seconds really does help a lot. I also fixed what was wrong with auto questing the money was not getting read right and the end_play button needed the same info as the pay button. You can check my complete script for the changes I made.



Re: @twelve27:

So far I've gotten missions and salary to work. I updated the complete script with the changes I have made but haven't updated the snippets yet. Testing out the idea I had on the salary function so far it seems to be running just fine.


My missions is in an infinite loop atm. I like your idea as well.


Basically we can add a couple lines of code to do this::

if (CAB === "" || CAB === undefined || CAB === 0) {
    getSalary();
}

That should failsafe into collecting if there is a need and also be able to refresh the page if there is nothing to collect.


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.


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: @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: @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: @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.



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: @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;
        }
    }

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:

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.


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.


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.