Roukys / HHauto

GNU General Public License v3.0
45 stars 44 forks source link

Request : Daily reward collection #341

Closed Roukys closed 2 years ago

Roukys commented 3 years ago

Allow to automatically collect Daily rewards.

Ideally only collect them on last day of month if possible

cossname commented 3 years ago

*upd 0.1: check if current page "home"

function dailyRewards() {
    if (getPage() == "home") {
        console.log('Trying to get daily rewards!')
        //Daily rewards notification check
        if ($('.daily-reward-notif').length > 0) {
            if ($('#no_HC')[0].style.display != "block") {
                $('.daily-reward-notif')[0].click();
            }
        }
        if ($('.tab.daily_rewards')[0].style.display == "block") {
            setTimeout(function () {
                //Daily rewards Tab visible?
                if ($('.tab.daily_rewards')[0].style.display == "block") {
                    if ($('.blue_button_L.daily-claim-btn:not([disabled])').length > 0) {
                        $('.blue_button_L.daily-claim-btn:not([disabled])')[0].click();
                        setTimeout(function () {
                            //Reload page to close reward popup (OK)
                            location.reload();
                        }, Math.random() * 1000 + 1000);
                    }
                }
            }, Math.random() * 2000 + 2000);
        }
    }
}

function getLastDayOfCurrentMonth() {
    let today = new Date();
    let date = new Date(today.getFullYear(), today.getMonth() + 1, 0);
    return date.getDate();
}

if (new Date().getDate() == getLastDayOfCurrentMonth()) {
    console.log('Detected last day of month!');
    dailyRewards();
} else {
    console.log('Waiting for last day of month!');
}
Diadochus-Ptolemy commented 3 years ago

Ideally only collect them on last day of month if possible

If you do not collect a reward, then the next day there will be no new one)

YotoTheOne commented 3 years ago

Is that so, or do you just need to connect to the game once a day to have the reward available ? In that case collecting could be delayed.

Diadochus-Ptolemy commented 3 years ago

Is that so, or do you just need to connect to the game once a day to have the reward available ? In that case collecting could be delayed.

I went into the game - there was an opportunity to pick up. Took it - there will be a new reward for the next day, if it didn’t take it - it will hang forever. In short, saving will not work.

Roukys commented 3 years ago

I've tried and it seems it does work as @Diadochus-Ptolemy says, I'll adapt script from @cossname to get reward at noon if not collected before

Roukys commented 3 years ago

@Diadochus-Ptolemy @YotoTheOne @cossname to be tested in 5.5.32

Olaf-san commented 3 years ago

The function is not working.

Roukys commented 3 years ago

@Olaf-san what isuue are you encountering ?

YotoTheOne commented 3 years ago

Well same here, it doesn't collect. Nothing relevant on the log.

Roukys commented 3 years ago

@YotoTheOne @Olaf-san it is set to collect only in the last hour of HH Day so 1 hour before end of competitions. event in the last hour it does not collect it ?

YotoTheOne commented 3 years ago

Ok, I don't think I waited this long before collecting manually. I'll wait this time. To be useful for the daily contest it only needs to be collected after 13h30, why did you choose to wait for the last hour ? Sometimes I cannot be around to reconnect the game after the weekly update that happens in the morning so those days I'll loose the reward if not collected before.

Olaf-san commented 3 years ago

I didn't know the script was collecting in the last hour. I thought it was after 13h30. I'm joining YotoTheOne, it would be better if it collected after 13h30.

Roukys commented 3 years ago

because during PoA could be useful to use it when needed during the day :)

OldRon1977 commented 3 years ago

I am indifferent according to the time, when to collect. But at least I can confirm, that the script is collecting. :) Before two days ago I always collected manually, because the red plus sign triggered me ;) So now I waited and it worked like @Roukys said and collected within the last hour.

Why would it be better to collect at a different time? Please give me a usecase, atm. I can't think of one. I would only advise to collect in the afternoon, so we are outside any update slots or rush-houres before a contest is ending.

YotoTheOne commented 3 years ago

Collecting before the weekly update would be nice, because the game often fails to reconnect after the update and I usually find about it when I get home at the end of the day. But it's not a big deal.

Olaf-san commented 3 years ago

To get everyone on the same page, we could associate a timer with the option right next to it. An area where you could write the time you want the script to collect the reward. What do you think about this?

Roukys commented 3 years ago

@Olaf-san Iwould not like to add a new field, would be good to reach a common agreement I've set it like that so everyone can collect it when needed during an event like PoA. What would beother proposals ? @YotoTheOne before update we could set it to be collected in last 4 hours of HH event day, what would you think ?

YotoTheOne commented 3 years ago

That would be ok. You could also leave it as it is, it works fine ; I'm collecting manually most of the time anyway, and in case i forget the script takes over. Maybe I'll loose a reward after an update occasionally, I'll survive !

Olaf-san commented 3 years ago

4 hours before seems to me a good compromise.