Browse Source

Expanded reloadTimer and exposed to injected div

main
Steven 1 year ago
parent
commit
4dc8e80c64
  1. 29
      tampermonkey.js

29
tampermonkey.js

@ -170,8 +170,10 @@ function winCounty(countyJson, saveChanges) {
//if we made it here no changes were needed to win by just the right amount
//Nothing else to do to win optimally
console.log(countyInfo +" is already winning by just the right amount");
//awLog(countyInfo +" is already winning by just the right amount");
} else if(countyJson.clicksToMinWin > 0) {
console.log(countyInfo +" is currently loosing. Increasing bid now");
//awLog(countyInfo +" is currently loosing. Increasing bid now");
for(var i = 0; i < countyJson.clicksToMinWin; i++) {
console.log("calling btnBidUp.click() for "+ countyInfo);
countyJson.btnBidUp.click();
@ -182,6 +184,7 @@ function winCounty(countyJson, saveChanges) {
}
} else if (countyJson.clicksToMinWin < 0) {
console.log(countyInfo +" is winning by too much. Decreasing bid now");
//awLog(countyInfo +" is winning by too much. Decreasing bid now");
let clicksRemaining = Math.abs(countyJson.clicksToMinWin);
while(clicksRemaining > 0) {
console.log("calling btnBidDown.click() for "+ countyInfo);
@ -199,6 +202,11 @@ function tieCounty(countyJson, saveChanges) {
//TODO: implemnt me
}
function awLog(message) {
console.log(message);
//const currentContent = document.getElementById("awLog").innerHTML;
document.getElementById("awLog").innerHTML = currentContent + message;
}
jQuery(window).on('load',function() {
console.log("Page loaded at: "+ new Date());
@ -212,7 +220,7 @@ jQuery(window).on('load',function() {
//Inject our controls
var newHTML = document.createElement ('div');
newHTML.innerHTML = '<div id="alwaysWin-ntsmhf"><label for="isReloadEnabled">AlwaysWin:</label><input type="checkbox" name="isReloadEnabled" '+ getCheckedValue() +'/><br/><label for="minSecondsBetweenReloads">Reload Every</label>:<input id="minSecondsBetweenReloads" type="text" size="3" name="minSecondsBetweenReloads" value="'+minSecondsBetweenReloads+'" /> to <input id="maxSecondsBetweenReloads" type="text" size="3" name="maxSecondsBetweenReloads" value="'+maxSecondsBetweenReloads+'" /> seconds</div>';
newHTML.innerHTML = '<div id="alwaysWin-ntsmhf"><label for="isReloadEnabled">AlwaysWin:</label><input type="checkbox" name="isReloadEnabled" '+ getCheckedValue() +'/><br/><label for="minSecondsBetweenReloads">Reload Every</label>:<input id="minSecondsBetweenReloads" type="text" size="3" name="minSecondsBetweenReloads" value="'+minSecondsBetweenReloads+'" /> to <input id="maxSecondsBetweenReloads" type="text" size="3" name="maxSecondsBetweenReloads" value="'+maxSecondsBetweenReloads+'" /> seconds <br/><div id="reloaderData"><div id="countdown"></div><progress value="0" max="100" id="progressBar" style="width: 100%;"></progress></div><div id="awLog" style="width:100%; border-style:ridge; background-color:#FEFEFE;" ">Log:</div></div>';
addAlwaysWinStyle('#alwaysWin-ntsmhf { position: fixed; top: 0px; left: 0px; background-color: #DDDDDD; border-radius: 5px; padding:2px; box-shadow: 5px 5px 3px #777777;}');
document.body.appendChild (newHTML);
@ -258,10 +266,19 @@ jQuery(window).on('load',function() {
//console.log("Saving county info stats");
const countyInfoStats = saveCountyInfoStats(newStats);
//Refresh the page when we are suposed to
let interval = setInterval(reload, secondsBetweenReloads*1000);
});
//Start our ui feedback for the enduser
var reloadTimeleft = secondsBetweenReloads;
var reloadTimer = setInterval(function() {
document.getElementById("countdown").innerHTML = "("+secondsBetweenReloads+") Next reload will occur in "+ reloadTimeleft +" seconds.";
var progressBarValue = 100 - Math.floor(100 * (reloadTimeleft / secondsBetweenReloads)); //Calculate percent complete
document.getElementById("progressBar").value = progressBarValue;
if(reloadTimeleft <= 0){
clearInterval(reloadTimer);
document.getElementById("countdown").innerHTML = secondsBetweenReloads +" second reload timer exhausted";
reload();
}
reloadTimeleft -= 1;
}, 1000);
});
Loading…
Cancel
Save