diff --git a/tampermonkey.js b/tampermonkey.js index bccce1b..18d5a2c 100644 --- a/tampermonkey.js +++ b/tampermonkey.js @@ -6,11 +6,13 @@ // @author Steven Allen // @match https://leads.needtosellmyhousefast.com/* // @require https://code.jquery.com/jquery-3.7.1.min.js +// @require http://crypto.stanford.edu/sjcl/sjcl.js // @icon https://www.google.com/s2/favicons?sz=64&domain=needtosellmyhousefast.com // @grant none // ==/UserScript== 'use strict'; + //Load our settings //localStorage.removeItem('alwayswin_settings'); @@ -26,7 +28,7 @@ if(alwaysWinSettingsString == null || alwaysWinSettingsString == undefined) { } var alwaysWinSettings = JSON.parse(alwaysWinSettingsString); -console.log(alwaysWinSettings); +//console.log(alwaysWinSettings); //////////// // Div injection and auto reload functions @@ -65,12 +67,15 @@ function saveSettings() { let minSecondsBetweenReloadsValue = document.querySelector("[name='minSecondsBetweenReloads']").value; let maxSecondsBetweenReloadsValue = document.querySelector("[name='maxSecondsBetweenReloads']").value; - const latestSettings = { - "isReloadEnabled": isReloadEnabledValue, - "isAutoLoginEnabled": isAutoLoginEnabledValue, - "minSecondsBetweenReloads": minSecondsBetweenReloadsValue, - "maxSecondsBetweenReloads": maxSecondsBetweenReloadsValue - }; + var latestSettings = alwaysWinSettings; + latestSettings.isReloadEnabled = isReloadEnabledValue; + latestSettings.isAutoLoginEnabled = isAutoLoginEnabledValue; + latestSettings.minSecondsBetweenReloads = minSecondsBetweenReloadsValue; + latestSettings.maxSecondsBetweenReloads = maxSecondsBetweenReloadsValue; + + //console.log("latestSettings"); + //console.log(latestSettings); + const latestSettingsString = JSON.stringify(latestSettings); localStorage.setItem('alwayswin_settings',latestSettingsString); @@ -96,14 +101,14 @@ function reload() { console.log("Saving settings..."); let alwaysWinSettings = saveSettings(); - console.log("Its time to perform a reload."); - console.log("isEnabled: "+ alwaysWinSettings.isReloadEnabled); - console.log("secondsBetweenReloads:"+ alwaysWinSettings.minSecondsBetweenReloads +" - "+ alwaysWinSettings.maxSecondsBetweenReloads); + awLog("Its time to perform a reload."); + awLog("isEnabled: "+ alwaysWinSettings.isReloadEnabled); + awLog("secondsBetweenReloads:"+ alwaysWinSettings.minSecondsBetweenReloads +" - "+ alwaysWinSettings.maxSecondsBetweenReloads); if(!reloadIsEnabled() ) { - console.log("Reload is not enabled"); + awLog("Reload is not enabled"); return; } - console.log("Reload is enabled. Reloading..."); + awLog("Reload is enabled. Reloading..."); location.reload(); } @@ -187,13 +192,13 @@ function winCounty(countyJson, saveChanges) { 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"); + awLog(countyInfo +" is currently loosing by "+countyJson.clicksToMinWin+" Increasing bid now"); for(var i = 0; i < countyJson.clicksToMinWin; i++) { - console.log("calling btnBidUp.click() for "+ countyInfo); + //console.log("calling btnBidUp.click() for "+ countyInfo); countyJson.btnBidUp.click(); } if(saveChanges) { - console.log("calling btnSave.click() for "+ countyInfo); + //console.log("calling btnSave.click() for "+ countyInfo); countyJson.btnSave.click(); } } else if (countyJson.clicksToMinWin < 0) { @@ -201,12 +206,12 @@ function winCounty(countyJson, saveChanges) { 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); + //console.log("calling btnBidDown.click() for "+ countyInfo); countyJson.btnBidDown.click(); clicksRemaining--; } if(saveChanges) { - console.log("calling btnSave.click() for "+ countyInfo); + //console.log("calling btnSave.click() for "+ countyInfo); countyJson.btnSave.click(); } } @@ -222,6 +227,14 @@ function awLog(message) { document.getElementById("awLog").innerHTML = currentContent +"
"+ message; } +function encryptAndStore(encryptionKey, clearText) { + return JSON.stringify(sjcl.encrypt(encryptionKey, clearText)); +} + +function unStoreAndDecrypt (encryptionKey, jsonObj) { + return sjcl.decrypt(encryptionKey, JSON.parse(jsonObj)); +} + function loginIfNeeded(){ var div_signin = document.querySelector('.signin-box'); var loginIsNeeded = false; @@ -234,13 +247,40 @@ function loginIfNeeded(){ 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; + + var encKey = alwaysWinSettings.encKey ?? ""; + var ntsmhfUser = alwaysWinSettings.ntsmhfUser ?? ""; + var ntsmhfPass = alwaysWinSettings.ntsmhfPass ?? ""; + if (!encKey) { + encKey = prompt('Script key not set for ' + location.hostname + '. Please enter a random string:',''); + alwaysWinSettings.encKey = encKey; + ntsmhfUser = ""; + ntsmhfPass = ""; + } + + if(ntsmhfUser) { + ntsmhfUser = unStoreAndDecrypt(encKey, ntsmhfUser); + } else { + ntsmhfUser = prompt('UserName is not set for '+ location.hostname +'. Enter it now:',''); + alwaysWinSettings.ntsmhfUser = encryptAndStore(encKey, ntsmhfUser); + } + + if(ntsmhfPass) { + ntsmhfPass = unStoreAndDecrypt(encKey, ntsmhfPass); + } else { + ntsmhfPass = prompt('Password is not set for '+ location.hostname +'. Enter it now:',''); + alwaysWinSettings.ntsmhfPass = encryptAndStore(encKey, ntsmhfPass); + } + + const latestSettingsString = JSON.stringify(alwaysWinSettings); + localStorage.setItem('alwayswin_settings',latestSettingsString); + ////// + + txt_email.value = ntsmhfUser; + txt_password.value = ntsmhfPass; btn_signin.click(); } return loginIsNeeded; @@ -263,7 +303,7 @@ jQuery(window).on('load',function() { newHtml += ' | '; newHtml += '
'; newHtml += ': to seconds
'; - newHtml += '
Log:
'; + newHtml += '
Log:
'; newHtml += ''; newDiv.innerHTML = newHtml;