From 4dc8e80c64d1c77aca42d548df7f99dc1c4c1587 Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 17 Nov 2023 21:21:26 -0800 Subject: [PATCH] Expanded reloadTimer and exposed to injected div --- tampermonkey.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/tampermonkey.js b/tampermonkey.js index 8feed56..123bb11 100644 --- a/tampermonkey.js +++ b/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 = '

: to seconds
'; + newHTML.innerHTML = '

: to seconds
Log:
'; 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); +}); \ No newline at end of file