1
0

fix: fix NaN parsing brNum

This commit is contained in:
2026-01-03 12:36:48 +01:00
parent 1e4fd576cb
commit 33e159815f

View File

@@ -3,7 +3,7 @@
// @namespace bing // @namespace bing
// @description Search for 30 random words on bing to rack up reward points, just search bing once to start script // @description Search for 30 random words on bing to rack up reward points, just search bing once to start script
// @include https://www.bing.com/* // @include https://www.bing.com/*
// @version 1.4 // @version 1.5
// @updateURL https://git.alexbcberio.com/alexbcberio/userscripts/raw/branch/main/bing-rewarder/index.js // @updateURL https://git.alexbcberio.com/alexbcberio/userscripts/raw/branch/main/bing-rewarder/index.js
// @downloadURL https://git.alexbcberio.com/alexbcberio/userscripts/raw/branch/main/bing-rewarder/index.js // @downloadURL https://git.alexbcberio.com/alexbcberio/userscripts/raw/branch/main/bing-rewarder/index.js
// @grant GM.registerMenuCommand // @grant GM.registerMenuCommand
@@ -17,7 +17,7 @@ const maxSearch = 30;
const wordMinLength = 4; const wordMinLength = 4;
const wordMaxLength = 10; const wordMaxLength = 10;
const minWaitSecondsToSearch = 5; const minWaitSecondsToSearch = 5;
const maxWaitSecondsToSearch = 10; const maxWaitSecondsToSearch = 20;
if (location.pathname === "/search" && !urlSearchParams.get("rnoreward")) { if (location.pathname === "/search" && !urlSearchParams.get("rnoreward")) {
newSearch(); newSearch();
@@ -31,6 +31,10 @@ function newSearch() {
} }
brNum = parseInt(brNum) + 1; brNum = parseInt(brNum) + 1;
if (isNaN(brNum)) {
brNum = 1;
}
if (brNum > maxSearch){ if (brNum > maxSearch){
return false; return false;
} }
@@ -38,7 +42,7 @@ function newSearch() {
// timeout to help disguise this as being a script // timeout to help disguise this as being a script
setTimeout(() => { setTimeout(() => {
doSearch(brNum); doSearch(brNum);
}, (Math.random() * maxWaitSecondsToSearch * 1e3) + minWaitSecondsToSearch * 1e3); }, (Math.random() * (maxWaitSecondsToSearch - minWaitSecondsToSearch) * 1e3) + minWaitSecondsToSearch * 1e3);
} }
function doSearch(iteration = 0) { function doSearch(iteration = 0) {