diff --git a/tampermonkey.js b/tampermonkey.js
index 123bb11..bccce1b 100644
--- a/tampermonkey.js
+++ b/tampermonkey.js
@@ -1,10 +1,10 @@
// ==UserScript==
-// @name AlwaysWin -ntsmhf
+// @name AlwaysWin-ntsmhf
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Make sure you are positioned where you want to be in the bidding for each county.
// @author Steven Allen
-// @match https://leads.needtosellmyhousefast.com/app
+// @match https://leads.needtosellmyhousefast.com/*
// @require https://code.jquery.com/jquery-3.7.1.min.js
// @icon https://www.google.com/s2/favicons?sz=64&domain=needtosellmyhousefast.com
// @grant none
@@ -19,7 +19,7 @@ var alwaysWinSettingsString = localStorage.getItem('alwayswin_settings');
//console.log(alwaysWinSettingsString);
if(alwaysWinSettingsString == null || alwaysWinSettingsString == undefined) {
- const defaultSettings = {"isReloadEnabled":true, "minSecondsBetweenReloads": 60, "maxSecondsBetweenReloads":300};
+ const defaultSettings = {"isReloadEnabled":true, "isAutoLoginEnabled":false, "minSecondsBetweenReloads": 60, "maxSecondsBetweenReloads":300};
const defaultSettingsString = JSON.stringify(defaultSettings);
localStorage.setItem('alwayswin_settings',defaultSettingsString);
alwaysWinSettingsString = defaultSettingsString;
@@ -37,11 +37,16 @@ function getRandomNumberBetween(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
-function getCheckedValue() {
- if(reloadIsEnabled()) {
- return "checked";
+function getCheckedValue(fieldName) {
+ switch (fieldName) {
+ case "isReloadEnabled":
+ return reloadIsEnabled() ? "checked": "";
+ case "isAutoLoginEnabled":
+ return autoLoginIsEnabled() ? "checked": "";
+ default:
+ return "";
}
- return;
+ return "";
}
function addAlwaysWinStyle(css) {
@@ -56,11 +61,13 @@ function addAlwaysWinStyle(css) {
function saveSettings() {
let isReloadEnabledValue = document.querySelector("[name='isReloadEnabled']").checked;
+ let isAutoLoginEnabledValue = document.querySelector("[name='isAutoLoginEnabled']").checked;
let minSecondsBetweenReloadsValue = document.querySelector("[name='minSecondsBetweenReloads']").value;
let maxSecondsBetweenReloadsValue = document.querySelector("[name='maxSecondsBetweenReloads']").value;
const latestSettings = {
"isReloadEnabled": isReloadEnabledValue,
+ "isAutoLoginEnabled": isAutoLoginEnabledValue,
"minSecondsBetweenReloads": minSecondsBetweenReloadsValue,
"maxSecondsBetweenReloads": maxSecondsBetweenReloadsValue
};
@@ -108,6 +115,13 @@ function reloadIsEnabled(){
return false;
}
+function autoLoginIsEnabled(){
+ var checkedValue = alwaysWinSettings.isAutoLoginEnabled ?? false;
+ var retVal = (checkedValue == true);
+ return retVal;
+}
+
+
////////////////////////////////////////////////////////////////////////////////////
// Always win code to find and take the highest/tie bid
////////////////////////////////////////////////////////////////////////////////////
@@ -169,11 +183,11 @@ function winCounty(countyJson, saveChanges) {
if(countyJson.clicksToMinWin == 0) {
//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");
+ //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");
+ //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();
@@ -183,8 +197,8 @@ function winCounty(countyJson, saveChanges) {
countyJson.btnSave.click();
}
} 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");
+ //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);
@@ -204,26 +218,74 @@ function tieCounty(countyJson, saveChanges) {
function awLog(message) {
console.log(message);
- //const currentContent = document.getElementById("awLog").innerHTML;
- document.getElementById("awLog").innerHTML = currentContent + message;
+ const currentContent = document.getElementById("awLog").innerHTML;
+ document.getElementById("awLog").innerHTML = currentContent +"
"+ message;
}
+function loginIfNeeded(){
+ var div_signin = document.querySelector('.signin-box');
+ var loginIsNeeded = false;
+ if(div_signin != undefined && div_signin != null) {
+ loginIsNeeded = true;
+
+ if(!alwaysWinSettings.isAutoLoginEnabled) {
+ console.log("AutoLogin is turned off.");
+ awLog("AutoLogin is turned off.");
+ return loginIsNeeded;
+ }
+ console.log("A signin dialog exists");
+ const user = "xxx";
+ const pass = "xxx";
+ var txt_email = div_signin.querySelector("[id='email']");
+ var txt_password = div_signin.querySelector("[id='inputPassword']");
+ var btn_signin = div_signin.querySelector('.btn-signin'); //btn btn-primary btn-block btn-signin
+ txt_email.value = user;
+ txt_password.value = pass;
+ btn_signin.click();
+ }
+ return loginIsNeeded;
+}
+
+const sleep = ms => new Promise(res => setTimeout(res, ms))
+
jQuery(window).on('load',function() {
console.log("Page loaded at: "+ new Date());
-
let minSecondsBetweenReloads = alwaysWinSettings.minSecondsBetweenReloads ?? 30;
let maxSecondsBetweenReloads = alwaysWinSettings.maxSecondsBetweenReloads ?? 60;
let isReloadEnabled = alwaysWinSettings.isReloadEnabled ?? false;
-
+ let isAutoLoginEnabled = alwaysWinSettings.isAutoLoginEnabled ?? false;
let secondsBetweenReloads = getRandomNumberBetween(minSecondsBetweenReloads, maxSecondsBetweenReloads);
console.log("Next reload should occur in "+ secondsBetweenReloads +" seconds");
//Inject our controls
- var newHTML = document.createElement ('div');
- newHTML.innerHTML = '