Skip to content

Instantly share code, notes, and snippets.

@vonalbert
Last active August 20, 2022 19:54
Show Gist options
  • Save vonalbert/afd436ad5d7d65a3c00e1b53acc9cf2c to your computer and use it in GitHub Desktop.
Save vonalbert/afd436ad5d7d65a3c00e1b53acc9cf2c to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Bing Searcher
// @namespace https://gist.github.com/vonalbert
// @version 1.4
// @downloadURL https://gist.github.com/vonalbert/afd436ad5d7d65a3c00e1b53acc9cf2c
// @updateURL https://gist.github.com/vonalbert/afd436ad5d7d65a3c00e1b53acc9cf2c
// @description Perform some searches on bing.com to make MS happy :)
// @author Alberto Avon
// @match http*://www.bing.com/*
// @grant none
// ==/UserScript==
const MAX_DELAY_MS = 8000;
const MIN_DELAY_MS = 3000;
const QUERY_MAX_WORDS = 4;
const MULTI_WORD_PERCENT = 65;
const FALLBACK_SEARCH = getRandomValue(["sony", "microsoft", "apple", "facebook", "amazon"]);
function getRandomValue(array) {
return array[Math.floor((Math.random()*array.length))];
}
(function() {
'use strict';
const hash = window.location.hash.substring(1);
const matches = hash.match(/^s(\d+)$/);
if (matches === null) {
return;
}
const iteration = parseInt(matches[1]);
if (iteration <= 0) {
return;
}
const waitDelay = (Math.random() * (MAX_DELAY_MS - MIN_DELAY_MS)) + MIN_DELAY_MS;
const dictionary = document.body.textContent.replace(/([a-z])([A-Z])/g, '$1 $2').toLowerCase()
.replace(/\W/g, ' ')
.split(/\s+/)
.filter((word, index, array) => word.length > 3 && array.indexOf(word) === index && word.match(/^[a-z]+$/i));
const queryWords = [];
do {
queryWords.push(getRandomValue(dictionary));
} while ((Math.random()*100) < MULTI_WORD_PERCENT);
let query = queryWords.join(" ").trim(" ");
if (query === "") {
query = FALLBACK_SEARCH;
}
const searchUrl = `https://www.bing.com/search?q=${query}#s${iteration-1}`;
console.log("Next search:", searchUrl, "will start in ", waitDelay/1000, " seconds");
setTimeout(() => window.open(searchUrl, "_self"), waitDelay);
})();
@vonalbert
Copy link
Author

vonalbert commented Jun 7, 2022

To start the search process just visit the url https://www.bing.com/#s40.
The provided link will perform 40 searches automatically. To change the number of searches to perform you only need to update the number at the end of the url.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment