Browse Source

Reformatted and Moved code around for readability

main
Steven 1 year ago
parent
commit
c4fb2953a8
  1. 32
      README.md
  2. 96
      tampermonkey.js

32
README.md

@ -9,21 +9,23 @@ To load the Tampermonkey script:
## Wishlist / Todo
### Functionality For Release
- [X] Expose buildNumber to settings view
- [ ] Add verbage to settings div that we are happy to JV on creative deals (get verbage from carolina)
- [X] Add this link to the settings div: https://leads.needtosellmyhousefast.com/qhrei (added this instead because it made more sense:https://info.qhrei.com/temp/alwayswin-ntsmhf/index.htm)
- [X] Add donation/support message to div
- [ ] Read from /app/subscriptions to get list of initial counties - if county is missing it automatically gets added.
- [x] Expose Sitewide bidcap (if any county bid exceeds X only bid up to X for that county)
- [x] Save button to persist changes (instead of waiting for refresh code to run)
- [x] Save settings to local storage
- [x] Retrieve settings from local storage
- [x] county bidcap - store and read from settings
- [X] Expose Sitewide bidcap (if any county bid exceeds X only bid up to X for that county)
- [X] Save button to persist changes (instead of waiting for refresh code to run)
- [X] Save settings to local storage
- [X] Retrieve settings from local storage
- [X] county bidcap - store and read from settings
- [ ] county isBidCapEnabled - store and read from settings
- [ ] use isBidCapEnabled when processing each oversight
- [ ] use bidcap when processing each oversight
- [ ] Implement tieCounty code
- [ ] Implement watchCounty code
- [x] Add cap presidence setting.
- [x] Add Presidence option to settings div
- [X] Add cap presidence setting.
- [X] Add Presidence option to settings div
*If a row and general cap are enabled then [options🔽] takes presidence.*
```
@ -61,23 +63,23 @@ To load the Tampermonkey script:
### UI Settings
- [x] How often should the status check be performed?
- [x] randomize refresh value to avoid detection
- [X] How often should the status check be performed?
- [X] randomize refresh value to avoid detection
### UI Rows
- [x] "rowAction" dropdown with options:
- [X] "rowAction" dropdown with options:
```
0 - Ignore/Hide = Make this row invisible.
1 - Win = Ensure I am highest bidder
2 - Tie = Make sure I am Tied
3 - Watch = Dont bid just monitor
```
- [x] expose countyId, tie, margin/clicksToWin data
- [X] expose countyId, tie, margin/clicksToWin data
- [ ] enable apply, enableBidcap, bidCap, action inputs and persist values the values at a row level
- [x] Store tie values for statistical analysis over time.
- [x] Auto login if on signin page
- [x] Add verticle scroll overflow to awLog div
- [x] Refactor injection and alwayswin array code in main
- [X] Store tie values for statistical analysis over time.
- [X] Auto login if on signin page
- [X] Add verticle scroll overflow to awLog div
- [X] Refactor injection and alwayswin array code in main
- [ ] Bidcap input for row is only visible if cap is checked for row or settings bidcap is enabled.
- [ ] Refactor Row injections layout to be:

96
tampermonkey.js

@ -13,6 +13,7 @@
'use strict';
const buildNumber = 0.125;
//Load our settings
//localStorage.removeItem('alwayswin_settings');
const verboseLevel=0;
@ -773,22 +774,12 @@ function injectOversight(countyId, action) {
targetContainer.appendChild(oversightPriceDiv);
}
const sleep = ms => new Promise(res => setTimeout(res, ms))
jQuery(window).on('load',function() {
console.log("Page loaded at: "+ new Date());
function injectSettingsDiv() {
let minSecondsBetweenReloads = alwaysWinSettings.minSecondsBetweenReloads ?? 30;
let maxSecondsBetweenReloads = alwaysWinSettings.maxSecondsBetweenReloads ?? 180;
let isReloadEnabled = alwaysWinSettings.isReloadEnabled ?? false;
let isAutoLoginEnabled = alwaysWinSettings.isAutoLoginEnabled ?? false;
let isGeneralCapEnabled = alwaysWinSettings.isGeneralCapEnabled ?? false;
let capPresidence = alwaysWinSettings.capPresidence ?? "row";
let generalCap = alwaysWinSettings.generalCap ?? 500;
let secondsBetweenReloads = getRandomNumberBetween(minSecondsBetweenReloads, maxSecondsBetweenReloads);
//console.log("Next reload should occur in "+ secondsBetweenReloads +" seconds");
//Inject our controls
var newDiv = document.createElement ('div');
var newHtml = '<div class="alwaysWin-ntsmhf" id="alwaysWin-ntsmhf">';
newHtml += '<input type="checkbox" name="isAutoLoginEnabled" '+ getCheckedValue("isAutoLoginEnabled") +'/><label for="isAutoLoginEnabled">Auto Login</label> | ';
@ -800,14 +791,15 @@ jQuery(window).on('load',function() {
newHtml += '<label for="generalCap">:</label><input id="generalCap" type="text" size="2" name="generalCap" value="'+ generalCap+'" title="Don&apos;t bid more than this amount per county" /> ';
newHtml += '<label for="capPresidence" title="If a row cap and general cap are both enabled..."> presidence:</label><select id="capPresidence" name="capPresidence" title="This takes presidence over any caps that may exist." />'+ getCapPresidenceOptions(capPresidence) +'</select><br/>';
newHtml += '<div id="reloaderData"><div id="countdown"></div><progress value="0" max="100" id="progressBar" style="width: 100%;"></progress></div><div id="awLog" class="alwaysWinLog"></div>';
newHtml += '<div id="support" class="alwaysWinSupport">Note: The bidcap functionality is currently under development is not being applied to any bids at the moment.</div>';
newHtml += '<div id="support" class="alwaysWinSupport">Note: The bidcap functionality is currently under development and is NOT being applied to any bids at the moment no matter what any messages say. The current bid IS accurate.</div>';
newHtml += '<div id="alwaysWinThanks" class="alwaysWinThanks">If you got any value out of this tool please feel free to show your support here: <a href="https://info.qhrei.com/temp/alwayswin-ntsmhf/index.htm" target="_blank">https://info.qhrei.com/tools/AlwaysWin-ntsmhf</a></div>';
newHtml += '<div id="buildNumber" class="buildNumber">v0.122</div>';
newHtml += '<div id="buildNumber" class="buildNumber">v'+ buildNumber +'</div>';
newHtml += '</div>';
newDiv.innerHTML = newHtml;
document.body.appendChild (newDiv);
addAlwaysWinStyle('.alwaysWin-ntsmhf {position: fixed; width:400px; top: 0px; left: 0px; background-color: #DDDDDD; border-radius: 5px; padding:2px; box-shadow: 5px 5px 3px #777777;}');
addAlwaysWinStyle('.alwaysWin-ntsmhf .alwaysWinLog {float:left; width:100%; overflow-y: auto; height: 100px; font-size: 0.75em; border-style:ridge; background-color:#FEFEFE;}');
@ -817,12 +809,55 @@ jQuery(window).on('load',function() {
addAlwaysWinStyle('.alwaysWin-ntsmhf .alwaysWinSupport {border: thick double #999999; width:100%; color: #111111; background-color: #44DDDD; padding: 1px 2px; text-align: left; text-decoration: none; display: inline-block; font-size: 12px; margin: 1px 1px; cursor: no-drop;}');
addAlwaysWinStyle('.alwaysWin-ntsmhf .buildNumber {position: absolute; top: 0; right: 0; text-align: left; color: #111111; font-size: 8px; padding:2px; cursor: context-menu;}');
addAlwaysWinStyle('.alwaysWin-ntsmhf .alwaysWinThanks {border: thick double #999999; width:100%; color: #CCCCCC; background-color: #444444; text-align: left; text-decoration: none; display: inline-block; font-size: 12px; padding: 2px; border-radius: 5px;}');
}
function calculateOversight() {
//TODO: Get rid of these calls and only read injections from settings (possible when apply button is coded)
// For now they will be commented out unless it's a first run of the script
//injectOversight("84035","win"); //washington, OR
//injectOversight("87833","win"); //marion, OR
//injectOversight("84034","tie"); //cascade, MT
//injectOversight("84037","win"); //clackamas, OR
//injectOversight("84038","watch"); //benton, OR
//injectOversight("87835","watch"); //multnomah, OR
//injectOversight("91976","win"); //CLARK, WA
}
document.body.appendChild (newDiv);
function registerEventListeners() {
const alwaysWinSave = document.getElementById("alwaysWin-ntsmhf-save");
alwaysWinSave.addEventListener("click", handleSaveSettings);
//TODO include overlays control event listers too?
}
function reloadPageAsNeeded() {
let minSecondsBetweenReloads = alwaysWinSettings.minSecondsBetweenReloads ?? 30;
let maxSecondsBetweenReloads = alwaysWinSettings.maxSecondsBetweenReloads ?? 180;
let secondsBetweenReloads = getRandomNumberBetween(minSecondsBetweenReloads, maxSecondsBetweenReloads);
//console.log("Next reload should occur in "+ secondsBetweenReloads +" seconds");
var reloadTimeleft = secondsBetweenReloads;
var reloadTimer = setInterval(function() {
var countdownElement = document.getElementById("countdown");
countdownElement.innerHTML = "Next reload will occur in "+ reloadTimeleft +" seconds.";
countdownElement.title = "Refesh timer started at "+secondsBetweenReloads+" 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);
}
jQuery(window).on('load',function() {
console.log("Page loaded at: "+ new Date());
//Inject our controls
injectSettingsDiv();
registerEventListeners();
//Only run our code on certain pages
//console.log(window.location.pathname);
@ -837,23 +872,14 @@ jQuery(window).on('load',function() {
}
//Are we logged in?
var logWasNeeded = loginIfNeeded();
if (logWasNeeded) {
if (loginIfNeeded()) {
return; //don't execute any more code until we are logged in.
}
//Inject our bits into the page for oversight
//TODO: Get rid of these calls and only read injections from settings (possible when apply button is coded)
// For now they will be commented out unless it's a first run of the script
//injectOversight("84035","win"); //washington, OR
//injectOversight("87833","win"); //marion, OR
//injectOversight("84034","tie"); //cascade, MT
//injectOversight("84037","win"); //clackamas, OR
//injectOversight("84038","watch"); //benton, OR
//injectOversight("87835","watch"); //multnomah, OR
//injectOversight("91976","win"); //CLARK, WA
calculateOversight();
//// Now do the work
//// Now do the work of updating bids as needed and displaying oversight info
let newStats = [];
let oversightCount = alwaysWinSettings.oversight.length;
awLog("Checking "+ oversightCount +" counties");
@ -885,18 +911,6 @@ jQuery(window).on('load',function() {
const countyInfoStats = saveCountyInfoStats(newStats);
//Start our ui feedback for the enduser
var reloadTimeleft = secondsBetweenReloads;
var reloadTimer = setInterval(function() {
var countdownElement = document.getElementById("countdown");
countdownElement.innerHTML = "Next reload will occur in "+ reloadTimeleft +" seconds.";
countdownElement.title = "Refesh timer started at "+secondsBetweenReloads+" 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);
reloadPageAsNeeded();
});
Loading…
Cancel
Save