// ==UserScript==
// @name Advanced Bing Search For Cooldown
// @namespace http://tampermonkey.net/
// @version 2.3
// @description Made By Sld Just For Educational Purpose
// @match https://www.bing.com/*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @grant GM_openInTab
// ==/UserScript==
(function() {
'use strict';
// Configuration
const CONFIG = {
STORAGE_KEYS: {
GLOBAL_SEARCHED_WORDS: 'globalSearchedWords',
TOTAL_SEARCH_COUNT: 'totalSearchCount',
PAGE_OPENED_BY_SCRIPT: 'pageOpenedByScript',
SEARCH_COUNT: 'searchCount'
},
TYPING_CONFIG: {
BASE_DELAY: 700,
VARIANCE_FACTOR: 400,
ERROR_CHANCE: 0.005,
CORRECTION_DELAY: 800
},
SEARCH_DELAYS: {
MIN: 8000,
MAX: 24000
},
WORD_SOURCES: [
'https://random-word-api.herokuapp.com/word?number=100',
'https://random-word-api.herokuapp.com/word?number=50'
],
CUSTOM_WORDS: [
'technology', 'innovation', 'science', 'learning',
'artificial intelligence', 'machine learning',
'programming', 'coding', 'development'
],
SEARCH_TIMEOUT: 20 * 60 * 1000, // 20 minutes in milliseconds
COOLDOWN_PERIOD: 15 * 60 * 1000, // 15 minutes in milliseconds
SEARCH_LIMIT: 5 // Number of searches before opening a new page
};
// Logger Utility
const Logger = {
log: (message) => console.log(`[Bing Automate Pro] ${message}`),
error: (message) => console.error(`[Bing Automate Error] ${message}`)
};
// Delay Manager
const DelayManager = {
getDelays(key) {
return GM_getValue(CONFIG.STORAGE_KEYS[key], []);
},
addDelay(key, delay) {
const delays = this.getDelays(key);
delays.push(delay);
GM_setValue(CONFIG.STORAGE_KEYS[key], delays);
},
getRandomDelay(min, max, usedDelays) {
let delay;
do {
delay = Math.floor(Math.random() * (max - min + 1)) + min;
} while (usedDelays.includes(delay));
return delay;
}
};
// Global Word Tracker
const GlobalWordTracker = {
getSearchedWords() {
return new Set(GM_getValue(CONFIG.STORAGE_KEYS.GLOBAL_SEARCHED_WORDS,
[]));
},
addSearchedWord(word) {
const searchedWords = this.getSearchedWords();
searchedWords.add(word.toLowerCase());
GM_setValue(CONFIG.STORAGE_KEYS.GLOBAL_SEARCHED_WORDS,
[...searchedWords]);
},
hasBeenSearched(word) {
return this.getSearchedWords().has(word.toLowerCase());
},
clearSearchedWords() {
GM_deleteValue(CONFIG.STORAGE_KEYS.GLOBAL_SEARCHED_WORDS);
}
};
// Word Manager
const WordManager = {
async fetchWords() {
try {
let allWords = [];
for (const url of CONFIG.WORD_SOURCES) {
const response = await fetch(url);
const words = await response.json();
allWords = allWords.concat(words);
}
allWords = [...new Set([...allWords, ...CONFIG.CUSTOM_WORDS])];
allWords = allWords.filter(word => !
GlobalWordTracker.hasBeenSearched(word));
return allWords;
} catch (error) {
Logger.error(`Word fetching failed: ${error.message}`);
return CONFIG.CUSTOM_WORDS;
}
},
async getUniqueWord() {
const words = await this.fetchWords();
if (words.length === 0) {
Logger.error('No new words available');
return null;
}
let selectedWord = words[Math.floor(Math.random() * words.length)];
while (!this.isValidWord(selectedWord)) {
selectedWord = words[Math.floor(Math.random() * words.length)];
}
return selectedWord;
},
isValidWord(word) {
return /^[a-zA-Z\s]+$/.test(word);
}
};
// Typing Simulator
const TypingSimulator = {
simulateTyping(element, text, onComplete) {
let currentIndex = 0;
const typingDelays = DelayManager.getDelays('TYPING_DELAYS');
const typeCharacter = () => {
const delay = CONFIG.TYPING_CONFIG.BASE_DELAY +
(Math.random() *
CONFIG.TYPING_CONFIG.VARIANCE_FACTOR);
DelayManager.addDelay('TYPING_DELAYS', delay);
if (Math.random() < CONFIG.TYPING_CONFIG.ERROR_CHANCE &&
currentIndex < text.length) {
const randomChar = String.fromCharCode(97 +
Math.floor(Math.random() * 26));
element.value += randomChar;
setTimeout(() => {
element.value = element.value.slice(0, -1);
element.value += text[currentIndex];
currentIndex++;
setTimeout(typeCharacter, delay);
}, CONFIG.TYPING_CONFIG.CORRECTION_DELAY);
} else if (currentIndex < text.length) {
element.value += text[currentIndex];
currentIndex++;
setTimeout(typeCharacter, delay);
} else {
onComplete();
}
};
typeCharacter();
}
};
// Search Performer
const SearchPerformer = {
async performSearch() {
const searchTerm = await WordManager.getUniqueWord();
if (!searchTerm) {
Logger.error('No search term available');
return;
}
const searchBox = document.getElementById('sb_form_q');
if (!searchBox) {
Logger.error('Search box not found');
return;
}
searchBox.value = '';
TypingSimulator.simulateTyping(searchBox, searchTerm, () => {
document.getElementById('sb_form').submit();
GlobalWordTracker.addSearchedWord(searchTerm);
const totalSearchCount =
GM_getValue(CONFIG.STORAGE_KEYS.TOTAL_SEARCH_COUNT, 0) + 1;
GM_setValue(CONFIG.STORAGE_KEYS.TOTAL_SEARCH_COUNT,
totalSearchCount);
const searchCount = GM_getValue(CONFIG.STORAGE_KEYS.SEARCH_COUNT,
0) + 1;
GM_setValue(CONFIG.STORAGE_KEYS.SEARCH_COUNT, searchCount);
updateOverlay();
if (searchCount >= CONFIG.SEARCH_LIMIT) {
GM_setValue(CONFIG.STORAGE_KEYS.SEARCH_COUNT, 0);
this.scheduleCooldown();
} else {
this.schedulePageRefresh();
}
});
},
schedulePageRefresh() {
const usedDelays = DelayManager.getDelays('SEARCH_DELAYS');
const refreshDelay =
DelayManager.getRandomDelay(CONFIG.SEARCH_DELAYS.MIN, CONFIG.SEARCH_DELAYS.MAX,
usedDelays);
DelayManager.addDelay('SEARCH_DELAYS', refreshDelay);
GM_setValue(CONFIG.STORAGE_KEYS.PAGE_OPENED_BY_SCRIPT, true);
setTimeout(() => {
location.reload();
}, refreshDelay);
},
scheduleCooldown() {
Logger.log(`Cooldown period of ${CONFIG.COOLDOWN_PERIOD / 60000}
minutes started.`);
setTimeout(() => {
Logger.log('Cooldown period ended. Performing next searches.');
GM_setValue(CONFIG.STORAGE_KEYS.PAGE_OPENED_BY_SCRIPT, true);
GM_openInTab('https://www.bing.com', { active: true, insert:
true });
}, CONFIG.COOLDOWN_PERIOD);
}
};
// Create CSS overlay
function createOverlay() {
const overlay = document.createElement('div');
overlay.id = 'bingAutomationOverlay';
overlay.style.position = 'fixed';
overlay.style.top = '10px';
overlay.style.right = '10px';
overlay.style.padding = '10px';
overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
overlay.style.color = '#fff';
overlay.style.zIndex = '9999';
overlay.style.borderRadius = '5px';
overlay.style.fontFamily = 'Arial, sans-serif';
overlay.innerHTML = `
<div>Total Searches: <span id="totalSearchCount">0</span></div>
`;
document.body.appendChild(overlay);
}
// Update CSS overlay
function updateOverlay() {
const totalSearchCount =
GM_getValue(CONFIG.STORAGE_KEYS.TOTAL_SEARCH_COUNT, 0);
document.getElementById('totalSearchCount').innerText = totalSearchCount;
}
// Initialize the script
async function initialize() {
createOverlay();
updateOverlay();
if (GM_getValue(CONFIG.STORAGE_KEYS.PAGE_OPENED_BY_SCRIPT, false)) {
Logger.log('Page opened by script, keeping search count');
} else {
Logger.log('Page opened manually, keeping search count');
}
GM_setValue(CONFIG.STORAGE_KEYS.PAGE_OPENED_BY_SCRIPT, false);
const usedDelays = DelayManager.getDelays('SEARCH_DELAYS');
const startDelay = DelayManager.getRandomDelay(CONFIG.SEARCH_DELAYS.MIN,
CONFIG.SEARCH_DELAYS.MAX, usedDelays);
DelayManager.addDelay('SEARCH_DELAYS', startDelay);
Logger.log(`Initializing search in ${startDelay / 1000} seconds`);
setTimeout(async () => {
await SearchPerformer.performSearch();
}, startDelay);
const searchTimeout = setTimeout(() => {
Logger.log('Closing tab due to inactivity.');
window.close();
}, CONFIG.SEARCH_TIMEOUT);
document.getElementById('sb_form').addEventListener('submit', () => {
clearTimeout(searchTimeout);
});
}
if (window.location.hostname === 'www.bing.com') {
initialize();
}
})();