Skip to content

Commit

Permalink
#139 Extend Time To Enter Calculator to Giveaways Manager
Browse files Browse the repository at this point in the history
Close #139
  • Loading branch information
Rafael committed Nov 5, 2017
1 parent 1b9278d commit 5f4cc27
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Extension/esgst.js
Original file line number Diff line number Diff line change
Expand Up @@ -17617,6 +17617,9 @@ function openGmPopout(giveaways, gm) {
if (esgst.gf && esgst.gf_s) {
gm.popout.popout.appendChild(new ButtonSet(`green`, `grey`, `fa-eye-slash`, `fa-circle-o-notch fa-spin`, `Hide Individual GAs`, `Hiding...`, hideGmGiveaways.bind(null, giveaways, gm)).set);
}
if (esgst.ttec) {
gm.popout.popout.appendChild(new ButtonSet(`green`, `grey`, `fa-clock-o`, `fa-circle-o-notch fa-spin`, `Calculate Time to Enter`, `Calculating...`, calculateGmGiveaways.bind(null, giveaways, gm)).set);
}
}
}

Expand Down Expand Up @@ -17833,6 +17836,29 @@ function hideGmGiveaways(giveaways, gm, callback) {
lockAndSaveGiveaways(newGiveaways, callback);
}

function calculateGmGiveaways(giveaways, gm, callback) {
let nextRefresh, points;
if (!giveaways) {
giveaways = esgst[gm.context ? `popupGiveaways` : `currentGiveaways`];
}
points = 0;
giveaways.forEach(giveaway => {
if (giveaway.gm && !giveaway.outerWrap.classList.contains(`esgst-hidden`) && !giveaway.ended) {
points += giveaway.points;
}
});
nextRefresh = 60 - new Date().getMinutes();
while (nextRefresh > 15) {
nextRefresh -= 15;
}
if (points > esgst.points) {
gm.textArea.value = `You will need to wait ${getTtecTime(Math.round((nextRefresh + (15 * Math.floor((points - esgst.points) / 6))) * 100) / 100)} to enter all selected giveaways for a total of ${points}P.${points > 400 ? `\n\nSince each 400P regeneration takes about 17h, you will need to return in 17h and use all your points so more can be regenerated.` : ``}`;
} else {
gm.textArea.value = `You have enough points to enter all giveaways right now.`;
}
callback();
}

/* [HGR] Hidden Games Remover */

function loadHgr() {
Expand Down

0 comments on commit 5f4cc27

Please sign in to comment.