Browse Source

Saving countyInfoStats to localStorage

main
Steven 1 year ago
parent
commit
2a81d98de9
  1. 5
      README.md
  2. 61
      tampermonkey.js

5
README.md

@ -18,6 +18,8 @@ To load the Tampermonkey script:
[] show rowAction2 array //AlwaysTie [] show rowAction2 array //AlwaysTie
[] show rowAction3 array //WatchTie [] show rowAction3 array //WatchTie
[] PriceChangeOverTime Chart [] PriceChangeOverTime Chart
[] Download Stats
[] Clear Stats
[] For each countyRow inject [] For each countyRow inject
[] "rowAction" dropdown with options: [] "rowAction" dropdown with options:
0 - Ignore 0 - Ignore
@ -27,7 +29,8 @@ To load the Tampermonkey script:
[] save to analytics checkbox [] save to analytics checkbox
[] county bidcap [] county bidcap
[] Option to sell leads that don't fit your criteria but you can't return on the secondary market. [] Option to sell leads that don't fit your criteria but you can't return on the secondary market.
[] Store tie values for statistical analysis over time. [x] Store tie values for statistical analysis over time.
[] Implement tieCounty code

61
tampermonkey.js

@ -72,6 +72,19 @@ function saveSettings() {
return latestSettings; return latestSettings;
} }
function saveCountyInfoStats(newStats) {
let existingStats = [];
//get existing stats if they exist
let existingStatsString = localStorage.getItem('alwayswin_stats');
if(existingStatsString != null && existingStatsString !== undefined) {
existingStats = JSON.parse(existingStatsString);
}
const combinedStats = existingStats.concat(newStats)
const updatedStatsString = JSON.stringify(combinedStats);
localStorage.setItem('alwayswin_stats',updatedStatsString);
//console.log(combinedStats);
}
function reload() { function reload() {
console.log("Saving settings..."); console.log("Saving settings...");
let alwaysWinSettings = saveSettings(); let alwaysWinSettings = saveSettings();
@ -129,6 +142,7 @@ function getCountyInfo(countyId){
num_clicksToMinWin = (winGap + bidIncriment) / bidIncriment; num_clicksToMinWin = (winGap + bidIncriment) / bidIncriment;
} }
bidController.readTimestamp = new Date();
bidController.isEnabled = county.checked; bidController.isEnabled = county.checked;
bidController.id = county.dataset.subscription_id; bidController.id = county.dataset.subscription_id;
bidController.name = county.closest("div").getElementsByTagName('a')[0].innerText; bidController.name = county.closest("div").getElementsByTagName('a')[0].innerText;
@ -181,6 +195,11 @@ function winCounty(countyJson, saveChanges) {
} }
} }
function tieCounty(countyJson, saveChanges) {
//TODO: implemnt me
}
jQuery(window).on('load',function() { jQuery(window).on('load',function() {
console.log("Page loaded at: "+ new Date()); console.log("Page loaded at: "+ new Date());
@ -202,23 +221,47 @@ jQuery(window).on('load',function() {
var countiesToWin = []; var countiesToWin = [];
countiesToWin.push("84035"); //washington, OR countiesToWin.push("84035"); //washington, OR
countiesToWin.push("87833"); //marion, OR countiesToWin.push("87833"); //marion, OR
//countiesToWin.push("84038"); //benton, OR
//countiesToWin.push("84037"); //clackamas, OR
//var countiesToTie = []; var countiesToTie = [];
//countiesToTie.push("84034"); //cascade, MT countiesToTie.push("84034"); //cascade, MT
//countiesToTie.push("84038"); //benton, OR
//countiesToTie.push("84037"); //clackamas, OR var countiesToWatch = [];
//tieCounty(getCountyInfo(countiesToTie[0].id); //countiesToWatch.push("84038"); //benton, OR
countiesToWatch.push("84037"); //clackamas, OR
let newStats = [];
let okToSaveChanges = true; let okToSaveChanges = true;
let countiesToWinCount = countiesToWin.length; let countiesToWinCount = countiesToWin.length;
for(var i = 0; i < countiesToWinCount; i++) { for(let i = 0; i < countiesToWinCount; i++) {
let currentEntity = getCountyInfo(countiesToWin[i]) let currentEntity = getCountyInfo(countiesToWin[i])
winCounty(currentEntity,okToSaveChanges); winCounty(currentEntity,okToSaveChanges);
newStats.push(currentEntity);
}
okToSaveChanges = true;
let countiesToTieCount = countiesToTie.length;
for(let i = 0; i < countiesToTieCount; i++) {
let currentEntity = getCountyInfo(countiesToTie[i])
tieCounty(currentEntity,okToSaveChanges);
newStats.push(currentEntity);
}
okToSaveChanges = false;
let countiesToWatchCount = countiesToWatch.length;
for(let i = 0; i < countiesToWatchCount; i++) {
let currentEntity = getCountyInfo(countiesToWatch[i])
tieCounty(currentEntity,okToSaveChanges);
newStats.push(currentEntity);
} }
//console.log("Saving county info stats");
const countyInfoStats = saveCountyInfoStats(newStats);
//Refresh the page when we are suposed to //Refresh the page when we are suposed to
let interval = setInterval(reload, secondsBetweenReloads*1000); let interval = setInterval(reload, secondsBetweenReloads*1000);
}); });

Loading…
Cancel
Save