feat: create bing-rewarder script
This commit is contained in:
80
bing-rewarder/index.js
Normal file
80
bing-rewarder/index.js
Normal file
@@ -0,0 +1,80 @@
|
||||
// ==UserScript==
|
||||
// @name Bing Rewarder
|
||||
// @namespace bing
|
||||
// @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/*
|
||||
// @version 1.3
|
||||
// @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
|
||||
// @grant GM.registerMenuCommand
|
||||
|
||||
// ==/UserScript==
|
||||
|
||||
GM.registerMenuCommand("Start searching", doSearch);
|
||||
|
||||
const urlSearchParams = new URLSearchParams(location.search);
|
||||
const maxSearch = 30;
|
||||
const wordMinLength = 4;
|
||||
const wordMaxLength = 10;
|
||||
const minWaitSecondsToSearch = 5;
|
||||
const maxWaitSecondsToSearch = 10;
|
||||
|
||||
if (location.pathname === "/search") {
|
||||
newSearch();
|
||||
}
|
||||
|
||||
function newSearch() {
|
||||
let brNum = urlSearchParams.get("brNum");
|
||||
|
||||
if (brNum == null){
|
||||
brNum = 0;
|
||||
}
|
||||
brNum = parseInt(brNum) + 1;
|
||||
|
||||
if (brNum > maxSearch){
|
||||
return false;
|
||||
}
|
||||
|
||||
// timeout to help disguise this as being a script
|
||||
setTimeout(() => {
|
||||
doSearch(brNum);
|
||||
}, (Math.random() * maxWaitSecondsToSearch * 1e3) + minWaitSecondsToSearch * 1e3);
|
||||
}
|
||||
|
||||
function doSearch(iteration = 0) {
|
||||
const wordLength = Math.floor((Math.random() * (wordMaxLength - wordMinLength)) + wordMinLength);
|
||||
const newQuery = createRandomWord(wordLength);
|
||||
|
||||
if (location.pathname === "/") {
|
||||
const form = document.querySelector("form");
|
||||
const searchInput = form.querySelector("[name=q]");
|
||||
|
||||
searchInput.value = newQuery;
|
||||
form.submit();
|
||||
return;
|
||||
}
|
||||
|
||||
urlSearchParams.set("q", newQuery);
|
||||
urlSearchParams.set("brNum", iteration);
|
||||
|
||||
location.search = urlSearchParams.toString();
|
||||
}
|
||||
|
||||
|
||||
// random word generator script, original source url
|
||||
// http://james.padolsey.com/javascript/random-word-generator/
|
||||
function createRandomWord(desiredLength) {
|
||||
var consonants = 'bcdfghjklmnpqrstvwxyz'.split(''),
|
||||
vowels = 'aeiou'.split(''),
|
||||
rand = function(limit) {
|
||||
return Math.floor(Math.random()*limit);
|
||||
},
|
||||
i, word='', length = parseInt(desiredLength,10);
|
||||
for (i=0;i<length/2;i++) {
|
||||
var randConsonant = consonants[rand(consonants.length)],
|
||||
randVowel = vowels[rand(vowels.length)];
|
||||
word += (i===0) ? randConsonant.toUpperCase() : randConsonant;
|
||||
word += i*2<length-1 ? randVowel : '';
|
||||
}
|
||||
return word;
|
||||
}
|
Reference in New Issue
Block a user