├── icons
├── icon16.png
├── icon32.png
├── icon48.png
└── icon128.png
├── README.md
├── gamemanual.js
├── manifest.json
├── contentscript.js
├── popup.css
├── popup.html
├── gamefix.js
├── script.js
├── popup.js
└── background.js
/icons/icon16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanPhuyal/BIngSearcher/HEAD/icons/icon16.png
--------------------------------------------------------------------------------
/icons/icon32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanPhuyal/BIngSearcher/HEAD/icons/icon32.png
--------------------------------------------------------------------------------
/icons/icon48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanPhuyal/BIngSearcher/HEAD/icons/icon48.png
--------------------------------------------------------------------------------
/icons/icon128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanPhuyal/BIngSearcher/HEAD/icons/icon128.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # BIngSearcher
2 | Perform multiple random searches on Bing.com for Microsoft Rewards
3 | Made with ChatGPT.
4 |
5 | Features::
6 | Search Preceise word or Random Generated String and choose correct answer for MSN Shopping Game.
7 |
8 | INSTALL:
9 | Just extract zip file and load unpacked extension or just drag drop it to extension manager after turning on developer option.
10 |
11 | USE::
12 | Enter Number of Desktop Search in D Field.
13 | Enter Number of Mobile Search in M Field.
14 | Select Search Type (Desktop&Mobile Recommended)
15 | Select String Generation Type (Random Recommended)
16 | Start Button to start the search, Stop Button to stop the search.
17 | Game button to start msn shopping game.
18 |
19 | SPECIAL THANKS TO: u/_IIIIIIII_IIIIIIIII_ on reddit
20 |
21 | Support me: [](https://paypal.me/anishphuyal/500)
22 |
--------------------------------------------------------------------------------
/gamemanual.js:
--------------------------------------------------------------------------------
1 | var msnShoppingGamePane = document.querySelector("shopping-page-base")
2 | ?.shadowRoot.querySelector("shopping-homepage")
3 | ?.shadowRoot.querySelector("msft-feed-layout")
4 | ?.shadowRoot.querySelector("msn-shopping-game-pane");
5 |
6 | if(msnShoppingGamePane != null){
7 | msnShoppingGamePane.gameSettings.newGameCountdown = 0;
8 | msnShoppingGamePane.style.gridArea = "slot2";
9 | msnShoppingGamePane.getGameResult = function(e) {
10 | if (e === msnShoppingGamePane.selectedCardIndex){
11 | localStorage.removeItem("gamesPerDay");
12 | msnShoppingGamePane.dailyLimitReached = false;
13 | if(msnShoppingGamePane.leaderboardRecord)
14 | msnShoppingGamePane.leaderboardRecord.dailyGuessingGamesPlayed = 0;
15 | return e === -1 ? shoppingGamePane.setAttribute('gamestate','active') : msnShoppingGamePane.gameState === "win" ? "win" : "lose";
16 | }
17 | };
18 | msnShoppingGamePane.getGameResult(-1);
19 | }
20 | else alert("Unable to locate the shopping game!");
21 |
--------------------------------------------------------------------------------
/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Bing Searcher",
3 | "version": "9.0",
4 | "manifest_version": 2,
5 | "description": "Perform multiple random searches on Bing.com for Microsoft Rewards and play MSN Shopping games",
6 | "icons": {
7 | "16": "icons/icon16.png",
8 | "32": "icons/icon32.png",
9 | "48": "icons/icon48.png",
10 | "128": "icons/icon128.png"
11 | },
12 | "browser_action": {
13 | "default_popup": "popup.html"
14 | },
15 | "permissions": [
16 | "activeTab",
17 | "tabs",
18 | "webRequest",
19 | "webRequestBlocking",
20 | "storage",
21 | "https://www.bing.com/*",
22 | "https://www.msn.com/*/shopping/*",
23 | "https://www.bing.com/shop*"
24 | ],"content_scripts": [
25 | {
26 | "js": [
27 | "contentscript.js"
28 | ],
29 | "matches": [
30 | "https://www.msn.com/*/shopping*",
31 | "https://www.bing.com/shop*"
32 | ]
33 | }
34 | ],
35 | "web_accessible_resources": [
36 | "gamefix.js"
37 | ],
38 | "background": {
39 | "scripts": ["background.js"],
40 | "persistent": true
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/contentscript.js:
--------------------------------------------------------------------------------
1 | // var switchAreaSlot = document.getElementById("scroll-to-game").checked;
2 | // var skipAuthCheck = document.getElementById("skip-auth").checked;
3 | // var autoLoadNextGame = document.getElementById("auto-play-again").checked;
4 | // var newGameCountdownTime = parseInt(document.getElementById("countdown-time").value);
5 | // var autoUpdateRewardsBalance = !skipAuthCheck;
6 | function gameFix() {
7 | var scroll = document.querySelector("shopping-page-base")
8 | ?.shadowRoot.querySelector("shopping-homepage")
9 | ?.shadowRoot.querySelector("cs-feed-layout")
10 | ?.shadowRoot.querySelector("msn-shopping-game-pane");
11 | if(scroll){
12 | scroll.scrollIntoView({behavior: 'smooth'});
13 | }
14 | else{
15 | setInterval(gameFix,1000);
16 | }
17 | chrome.storage.local.set({ buttonClicked: "" });
18 | var s = document.createElement('script');
19 | s.src = chrome.runtime.getURL('gamefix.js');
20 | s.onload = function () {
21 | this.remove();
22 | // Code to be executed after the script is loaded and executed
23 | };
24 | (document.head || document.documentElement).appendChild(s);
25 |
26 | }
27 |
28 | chrome.storage.local.get(['buttonClicked'], function (result) {
29 | var buttonClicked = result.buttonClicked;
30 | if (typeof buttonClicked !== 'undefined') {
31 | if (buttonClicked === 'gameFixButton') {
32 | gameFix();
33 | }
34 | }
35 | });
36 |
--------------------------------------------------------------------------------
/popup.css:
--------------------------------------------------------------------------------
1 | body {
2 | background-color: #15191d;
3 | width: 240px;
4 | font-family: Arial, sans-serif;
5 | font-size: 14px;
6 | line-height: 1.5;
7 | padding: 10px;
8 | }
9 |
10 | h1 {
11 | color: #bfbfbf;
12 | font-size: 24px;
13 | font-weight: bold;
14 | margin-bottom: 20px;
15 | }
16 |
17 | label {
18 | color: #bfbfbf;
19 | display: inline-block;
20 | margin-bottom: 10px;
21 | text-align: right;
22 | }
23 |
24 | select, input[type=number] {
25 | padding: 5px;
26 | display: inline-block;
27 | border-radius: 3px;
28 | border: 1px solid #ccc;
29 | margin-bottom: 10px;
30 | }
31 | #preceise,#random{
32 | color: #bfbfbf;
33 |
34 |
35 | }
36 |
37 | button[type=submit] {
38 | background-color: #0078d4;
39 | color: #fff;
40 | border: none;
41 | /* height: 100%;
42 | width: 100%; */
43 | padding: 10px 18px;
44 | border-radius: 3px;
45 | cursor: pointer;
46 | }
47 | table {
48 | width: 70%;
49 | }
50 |
51 | td {
52 | height: 35px;
53 | }
54 | button[type=submit]:hover {
55 | background-color: #005a9e;
56 | }
57 | button[type=button] {
58 | background-color: #0078d4;
59 | color: #fff;
60 | border: none;
61 | /* padding: 10px 18px; */
62 | padding: 10px;
63 | /* height: 100%;
64 | width: 100%; */
65 | border-radius: 3px;
66 | cursor: pointer;
67 | }
68 |
69 | button[type=button]:hover {
70 | background-color: #005a9e;
71 | }
72 | p{
73 | color: #a50000;
74 | font-size: 10px;
75 | }
76 | .check{
77 | font-size: 14px;
78 | }
79 | .check input[type=number] {
80 | padding: 2px;
81 | display: inline-block;
82 | border-radius: 3px;
83 | border: 1px solid #ccc;
84 | margin-bottom: 5px;
85 | margin-right: 5px;
86 | width: 30px; /* Adjust the width to your desired value */
87 | }
88 |
--------------------------------------------------------------------------------
/popup.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Bing Searcher
5 |
6 |
7 |
8 |
9 | Bing Searcher
10 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/gamefix.js:
--------------------------------------------------------------------------------
1 | (async function () {
2 | var playAgain = null;
3 | document.querySelector("shopping-page-base")
4 | ?.shadowRoot.querySelector("shopping-homepage")
5 | ?.shadowRoot.querySelector("cs-feed-layout")
6 | ?.shadowRoot.querySelector("msn-shopping-game-pane").setAttribute('gamestate', 'active');
7 |
8 | var shoppingGame = document.querySelector("shopping-page-base")
9 | ?.shadowRoot.querySelector("shopping-homepage")
10 | ?.shadowRoot.querySelector("cs-feed-layout")
11 | ?.shadowRoot.querySelector("msn-shopping-game-pane")
12 | ?.shadowRoot.querySelector("msft-stripe");
13 |
14 | async function executeScript() {
15 | console.log("Executing");
16 | var pricesAll = []; // Array to store original prices
17 | var discountAll = []; // Array to store discounts
18 | var finalPrice = [];
19 | var cheapestIndex; // Store the index of the cheapest item
20 |
21 |
22 | async function pricesOfAll() {
23 | var prices = document
24 | .querySelector("shopping-page-base")
25 | ?.shadowRoot.querySelector("shopping-homepage")
26 | ?.shadowRoot.querySelector("cs-feed-layout")
27 | ?.shadowRoot.querySelector("msn-shopping-game-pane").displayedShoppingEntities;
28 |
29 | var loopTimes = prices.length;
30 | for (let i = 0; i < loopTimes; i++) {
31 | pricesAll.push(prices[i].priceInfo.originalPrice); // Add original price to pricesAll array
32 | discountAll.push(prices[i].dealPercentage); // Add discount to discountAll array
33 | }
34 | }
35 |
36 | async function calculateDiscount() {
37 | for (let i = 0; i < pricesAll.length; i++) {
38 | let initPrice = parseFloat(pricesAll[i].replace(/[$,]/g, ""));
39 | let discountPercentage = parseFloat(discountAll[i].replace("%", ""));
40 | let discountedPrice = (initPrice - ((initPrice * discountPercentage) / 100));
41 | finalPrice.push(discountedPrice);
42 | }
43 | }
44 | async function findCheapestIndex(finalPrice) {
45 | var cheapestPrice = Math.min(...finalPrice); // Find the lowest value in the finalPrice array
46 | var cheapIndex = finalPrice.indexOf(cheapestPrice); // Get the index of the lowest value
47 | return cheapIndex;
48 | }
49 |
50 | async function highlightAndRemoveItems(correctIndex, items) {
51 | for (let i = 0; i < items.length; i++) {
52 | if (i === correctIndex) {
53 | items[i].style.borderColor = "green";
54 | } else {
55 | items[i].style.display = "none";
56 | }
57 | }
58 | pricesAll = [];
59 | discountAll = [];
60 | finalPrice = [];
61 | cheapestIndex = null;
62 |
63 | }
64 | async function playAgainFunc() {
65 | // Get the initial shadow DOM element
66 | const firstShadowRoot = document.querySelector("#root > div > div > fluent-design-system-provider > div > div:nth-child(4) > div > shopping-page-base").shadowRoot;
67 |
68 | // Traverse through the shadow DOM to find the desired elements
69 | const shoppingHomepage = firstShadowRoot.querySelector("div > div.shopping-page-content > shopping-homepage").shadowRoot;
70 | const csFeedLayout = shoppingHomepage.querySelector("div > cs-feed-layout").shadowRoot;
71 | const shoppingGamePane = csFeedLayout.querySelector("msn-shopping-game-pane").shadowRoot;
72 | const gamePanelContainer = shoppingGamePane.querySelector("div.shopping-game-pane-container > div.game-panel-container > div.game-panel-header-2");
73 | if(gamePanelContainer){
74 | // Search for a button with the text "Play Again" within the div
75 | playAgain = gamePanelContainer.querySelectorAll("button")[0];
76 | }
77 | if (playAgain !== null) {
78 | console.log("Terminating playAgainFunc(): playAgain button found!");
79 | playAgain.click();
80 | clearInterval(fixIntervalId);
81 | playAgain=null;
82 | setTimeout(async function() {
83 | await executeScript();
84 | }, 8000); // 8000 milliseconds = 8 seconds
85 |
86 | // setTimeout(() => executeScript(), 9000);
87 | }
88 | }
89 | await pricesOfAll();
90 | await calculateDiscount();
91 | cheapestIndex = await findCheapestIndex(finalPrice);
92 | await highlightAndRemoveItems(cheapestIndex, shoppingGame.getElementsByClassName("shopping-game-card-outline"));
93 | // Only schedule the setTimeout if playAgain is still null
94 | var fixIntervalId = setInterval(async function () {
95 | await playAgainFunc();
96 | }, 100);
97 | }
98 | await executeScript();
99 | })();
100 |
--------------------------------------------------------------------------------
/script.js:
--------------------------------------------------------------------------------
1 | (async function () {
2 | var playAgain = null;
3 | document.querySelector("shopping-page-base")
4 | ?.shadowRoot.querySelector("shopping-homepage")
5 | ?.shadowRoot.querySelector("cs-feed-layout")
6 | ?.shadowRoot.querySelector("msn-shopping-game-pane").setAttribute('gamestate', 'active');
7 |
8 | var shoppingGame = document.querySelector("shopping-page-base")
9 | ?.shadowRoot.querySelector("shopping-homepage")
10 | ?.shadowRoot.querySelector("cs-feed-layout")
11 | ?.shadowRoot.querySelector("msn-shopping-game-pane")
12 | ?.shadowRoot.querySelector("msft-stripe");
13 |
14 | async function executeScript() {
15 | console.log("Executing");
16 | var pricesAll = []; // Array to store original prices
17 | var discountAll = []; // Array to store discounts
18 | var finalPrice = [];
19 | var cheapestIndex; // Store the index of the cheapest item
20 |
21 |
22 | async function pricesOfAll() {
23 | var prices = document
24 | .querySelector("shopping-page-base")
25 | ?.shadowRoot.querySelector("shopping-homepage")
26 | ?.shadowRoot.querySelector("cs-feed-layout")
27 | ?.shadowRoot.querySelector("msn-shopping-game-pane").displayedShoppingEntities;
28 |
29 | var loopTimes = prices.length;
30 | for (let i = 0; i < loopTimes; i++) {
31 | pricesAll.push(prices[i].priceInfo.originalPrice); // Add original price to pricesAll array
32 | discountAll.push(prices[i].dealPercentage); // Add discount to discountAll array
33 | }
34 | }
35 |
36 | async function calculateDiscount() {
37 | for (let i = 0; i < pricesAll.length; i++) {
38 | let initPrice = parseFloat(pricesAll[i].replace(/[$,]/g, ""));
39 | let discountPercentage = parseFloat(discountAll[i].replace("%", ""));
40 | let discountedPrice = (initPrice - ((initPrice * discountPercentage) / 100));
41 | finalPrice.push(discountedPrice);
42 | }
43 | }
44 | async function findCheapestIndex(finalPrice) {
45 | var cheapestPrice = Math.min(...finalPrice); // Find the lowest value in the finalPrice array
46 | var cheapIndex = finalPrice.indexOf(cheapestPrice); // Get the index of the lowest value
47 | return cheapIndex;
48 | }
49 |
50 | async function highlightAndRemoveItems(correctIndex, items) {
51 | for (let i = 0; i < items.length; i++) {
52 | if (i === correctIndex) {
53 | items[i].style.borderColor = "green";
54 | } else {
55 | items[i].style.display = "none";
56 | }
57 | }
58 | pricesAll = [];
59 | discountAll = [];
60 | finalPrice = [];
61 | cheapestIndex = null;
62 |
63 | }
64 | async function playAgainFunc() {
65 | // Get the initial shadow DOM element
66 | const firstShadowRoot = document.querySelector("#root > div > div > fluent-design-system-provider > div > div:nth-child(4) > div > shopping-page-base").shadowRoot;
67 |
68 | // Traverse through the shadow DOM to find the desired elements
69 | const shoppingHomepage = firstShadowRoot.querySelector("div > div.shopping-page-content > shopping-homepage").shadowRoot;
70 | const csFeedLayout = shoppingHomepage.querySelector("div > cs-feed-layout").shadowRoot;
71 | const shoppingGamePane = csFeedLayout.querySelector("msn-shopping-game-pane").shadowRoot;
72 | const gamePanelContainer = shoppingGamePane.querySelector("div.shopping-game-pane-container > div.game-panel-container > div.game-panel-header-2");
73 | if(gamePanelContainer){
74 | // Search for a button with the text "Play Again" within the div
75 | playAgain = gamePanelContainer.querySelectorAll("button")[0];
76 | }
77 | if (playAgain !== null) {
78 | console.log("Terminating playAgainFunc(): playAgain button found!");
79 | playAgain.click();
80 | clearInterval(fixIntervalId);
81 | playAgain=null;
82 | setTimeout(async function() {
83 | await executeScript();
84 | }, 9000); // 5000 milliseconds = 5 seconds
85 |
86 | // setTimeout(() => executeScript(), 9000);
87 | }
88 | }
89 | await pricesOfAll();
90 | await calculateDiscount();
91 | cheapestIndex = await findCheapestIndex(finalPrice);
92 | await highlightAndRemoveItems(cheapestIndex, shoppingGame.getElementsByClassName("shopping-game-card-outline"));
93 | // Only schedule the setTimeout if playAgain is still null
94 | var fixIntervalId = setInterval(async function () {
95 | await playAgainFunc();
96 | }, 100);
97 | }
98 | await executeScript();
99 | })();
100 |
--------------------------------------------------------------------------------
/popup.js:
--------------------------------------------------------------------------------
1 | var mobileUserAgent =
2 | "Mozilla/5.0 (Linux; Android 10; SM-G970F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Mobile Safari/537.36";
3 | var intervalId;
4 | var searchType;
5 | var searchGen;
6 |
7 | document.addEventListener("DOMContentLoaded", function () {
8 | var form = document.getElementById("search-form");
9 | var stopButton = document.getElementById("stop-button");
10 | var gameFixButton = document.getElementById("game-fix-button");
11 |
12 | // Define the webRequest listener
13 | function modifyUserAgent(details) {
14 | for (var i = 0; i < details.requestHeaders.length; ++i) {
15 | if (details.requestHeaders[i].name === "User-Agent") {
16 | details.requestHeaders[i].value = mobileUserAgent;
17 | break;
18 | }
19 | }
20 | return { requestHeaders: details.requestHeaders };
21 | }
22 |
23 | // Add event listeners
24 | form.addEventListener("submit", function (event) {
25 | event.preventDefault();
26 | var numSearchesD = document.getElementById("num-searchesD").value;
27 | var numSearchesM = document.getElementById("num-searchesM").value;
28 | searchType = document.getElementById("search-type").value;
29 | searchGen = document.querySelector('input[name="search-gen"]:checked').value;
30 |
31 | // Add the webRequest listener if mobile search is selected
32 | if (searchType === "mobile") {
33 | chrome.webRequest.onBeforeSendHeaders.addListener(
34 | modifyUserAgent,
35 | { urls: [""] },
36 | ["blocking", "requestHeaders"]
37 | );
38 | }
39 |
40 | chrome.storage.sync.get("isSearching", function (data) {
41 | if(data.isSearching=== "undefined"){
42 | chrome.storage.sync.set({ isSearching: true });
43 | }
44 | });
45 |
46 | chrome.storage.sync.get("isSearching", function (data) {
47 | if (data.isSearching === true) {
48 | console.log("TERMINATING SEARCH");
49 | return;
50 | } else {
51 | console.log("SEARCHING NOW");
52 | chrome.storage.sync.set({ isSearching: true });
53 | // Send message to background script to start searches
54 | chrome.runtime.sendMessage({
55 | type: "start-searches",
56 | numSearchesD: numSearchesD,
57 | numSearchesM: numSearchesM,
58 | searchType: searchType,
59 | searchGen: searchGen,
60 | });
61 | }
62 | });
63 |
64 | // // Send message to background script to start searches
65 | // chrome.runtime.sendMessage({
66 | // type: "start-searches",
67 | // numSearchesD: numSearchesD,
68 | // numSearchesM: numSearchesM,
69 | // searchType: searchType,
70 | // searchGen: searchGen,
71 | // });
72 |
73 | // Store the interval ID so that it can be cleared later
74 | intervalId = setInterval(function () {
75 | // Do something at each interval, if needed
76 | }, 1000);
77 | });
78 |
79 | stopButton.addEventListener("click", function (event) {
80 | clearInterval(intervalId);
81 |
82 | // Remove the webRequest listener if mobile search is selected
83 | if (searchType === "mobile") {
84 | chrome.webRequest.onBeforeSendHeaders.removeListener(modifyUserAgent);
85 | }
86 |
87 | // Send message to background script to stop searches
88 | chrome.runtime.sendMessage({ type: "stop-searches" });
89 | });
90 |
91 | // Retrieve the last value searched by the user (if any)
92 | chrome.storage.sync.get("lastSearchValueD", function (data) {
93 | if (data.lastSearchValueD) {
94 | document.getElementById("num-searchesD").value = data.lastSearchValueD;
95 | }
96 | });
97 | // Retrieve the last value searched by the user (if any)
98 | chrome.storage.sync.get("lastSearchValueM", function (data) {
99 | if (data.lastSearchValueM) {
100 | document.getElementById("num-searchesM").value = data.lastSearchValueM;
101 | }
102 | });
103 | // Retrieve the last value searched by the user (if any)
104 | chrome.storage.sync.get("lastTypeValue", function (data) {
105 | if (data.lastTypeValue) {
106 | document.getElementById("search-type").value = data.lastTypeValue;
107 | }
108 | });
109 | // Retrieve the last value searched by the user (if any)
110 | chrome.storage.sync.get("lastMethodValue", function (data) {
111 | if (data.lastMethodValue) {
112 | var searchGen = data.lastMethodValue;
113 | var radioButtons = document.querySelectorAll('input[name="search-gen"]');
114 | for (var i = 0; i < radioButtons.length; i++) {
115 | if (radioButtons[i].value === searchGen) {
116 | radioButtons[i].checked = true;
117 | break;
118 | }
119 | }
120 | }
121 | });
122 |
123 |
124 | // Listen for form submission and save the search value to storage
125 | document.getElementById("search-form").addEventListener("submit", function (event) {
126 | event.preventDefault();
127 | const numSearchesD = document.getElementById("num-searchesD").value;
128 | const numSearchesM = document.getElementById("num-searchesM").value;
129 | const searchType = document.getElementById("search-type").value;
130 | const searchGen = document.querySelector('input[name="search-gen"]:checked').value;
131 | // Save the search value to storage
132 | chrome.storage.sync.set({ lastSearchValueD: numSearchesD });
133 | chrome.storage.sync.set({ lastSearchValueM: numSearchesM });
134 | chrome.storage.sync.set({ lastTypeValue: searchType });
135 | chrome.storage.sync.set({ lastMethodValue: searchGen });
136 | });
137 |
138 | gameFixButton.addEventListener('click', function () {
139 | console.log("CLICKE");
140 | var buttonClicked = "gameFixButton";
141 | chrome.storage.local.set({ buttonClicked: buttonClicked }, function () {
142 | chrome.tabs.executeScript({
143 | file: 'contentscript.js'
144 | });
145 | });
146 | });
147 |
148 |
149 | // gameButton.addEventListener('click', function() {
150 | // chrome.tabs.executeScript({
151 | // file: 'contentscript.js',
152 | // code: 'var buttonClicked = "gameButton";'
153 | // });
154 | // });
155 | // gameFixButton.addEventListener('click', function() {
156 | // chrome.tabs.executeScript({
157 | // file: 'contentscript.js',
158 | // code: 'var buttonClicked = "gameFixButton";'
159 | // });
160 | // });
161 |
162 |
163 | });
164 |
--------------------------------------------------------------------------------
/background.js:
--------------------------------------------------------------------------------
1 | var intervalId;
2 | var desktopUserAgent = navigator.userAgent;
3 | var mobileUserAgent = "Mozilla/5.0 (Linux; Android 11; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Mobile Safari/537.36";
4 | // var mobileUserAgent = "Mozilla/5.0 (Linux; Android 10; SM-G970F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Mobile Safari/537.36";
5 | // var mobileUserAgent = "Mozilla/5.0 (Linux; {Android Version}; {Build Tag etc.}) AppleWebKit/{WebKit Rev} (KHTML, like Gecko) Chrome/{Chrome Rev} Mobile Safari/{WebKit Rev}";
6 | var userAgent = navigator.userAgent;
7 | var result="";
8 | var activeTabId = null;
9 | var searchUrl;
10 | var stopSearch = false;
11 | var randomTime=1000;
12 |
13 | async function randomTimeB(){
14 | const possibleValues = [1123, 2765, 3276, 3543];
15 | const randomIndex = Math.floor(Math.random() * possibleValues.length);
16 | const newTime = possibleValues[randomIndex];
17 | randomTime = newTime;
18 | }
19 |
20 | function modeSearch(numSearchesD,numSearchesM, searchType, searchGen){
21 | if (searchType === "desktop") {
22 | desktopSearch(numSearchesD,numSearchesM,searchType,searchGen);
23 | } else if (searchType === "mobile") {
24 | mobileSearch(numSearchesD,numSearchesM,searchType,searchGen);
25 | }else if(searchType === "desktopmobile"){
26 | desktopMobileSearch(numSearchesD,numSearchesM,searchType,searchGen);
27 | }
28 | else {
29 | chrome.storage.sync.set({ isSearching: false });
30 | console.error("Invalid search type: " + searchType);
31 | return;
32 | }
33 | }
34 |
35 | function delay(ms) {
36 | return new Promise(resolve => setTimeout(resolve, ms));
37 | }
38 |
39 | async function desktopMobileSearch(numSearchesD, numSearchesM, searchType, searchGen) {
40 | if (searchType === "desktopmobile") {
41 | console.log("Executing Desktop and Mobile Search");
42 |
43 | if (numSearchesM > 0) {
44 | await mobileSearch(numSearchesD,numSearchesM,"mobileM", searchGen);
45 | console.log("Finished performing mobile search.");
46 | }
47 |
48 | await desktopSearch(numSearchesD,numSearchesM,"desktopD" ,searchGen);
49 | console.log("Finished performing desktop search.");
50 |
51 | // await delay(numSearchesD * 1000);
52 | } else {
53 | chrome.storage.sync.set({ isSearching: false });
54 | console.error("Invalid search type: " + searchType);
55 | return;
56 | }
57 | }
58 |
59 |
60 | async function desktopSearch(numSearchesD,numSearchesM,searchType,searchGen) {
61 | if (searchType === "desktop"||searchType === "desktopD") {
62 | searchUrl = "https://www.bing.com/search?q=";
63 | userAgent = desktopUserAgent;
64 | } else {
65 | chrome.storage.sync.set({ isSearching: false });
66 | console.error("Invalid search type: " + searchType);
67 | return;
68 | }
69 | await actualSearch(numSearchesD,numSearchesM, searchType, searchGen);
70 | }
71 |
72 | async function mobileSearch(numSearchesD,numSearchesM,searchType, searchGen) {
73 | if (searchType === "mobile"||searchType === "mobileM") {
74 | searchUrl = "https://www.bing.com/search?q=";
75 | userAgent = mobileUserAgent;
76 | } else {
77 | chrome.storage.sync.set({ isSearching: false });
78 | console.error("Invalid search type: " + searchType);
79 | return;
80 | }
81 | await actualSearch(numSearchesD,numSearchesM, searchType, searchGen);
82 | }
83 |
84 | async function actualSearch(numSearchesD,numSearchesM, searchType, searchGen) {
85 | var searchCount = 0;
86 | var prevSearches = [];
87 | var numSearches=0 ;
88 | result="";
89 |
90 | if(searchType==="desktop" ||searchType==="desktopD"){
91 | numSearches = numSearchesD;
92 | }else if(searchType==="mobile"||searchType==="mobileM"){
93 | numSearches =numSearchesM;
94 | }
95 | while (searchCount < numSearches) {
96 | if (searchGen == "precise") {
97 | var searchTerm = await generateSearchTerm();
98 | } else if (searchGen == "random") {
99 | var searchTerm = "";
100 | if(searchType==="desktop"||searchType==="desktopD"){
101 | searchTerm = await generateString(numSearchesD);
102 | }else if(searchType==="mobile"||searchType==="mobileM"){
103 | searchTerm = await generateString(numSearchesM);
104 | }
105 |
106 | } else {
107 | console.log("Error, (Random/Preceise)");
108 | return;
109 | }
110 |
111 | if (stopSearch) {
112 | chrome.storage.sync.set({ isSearching: false });
113 | searchCount=0;
114 | result = "";
115 | if (searchType === "mobile"||searchType==="mobileM") {
116 | userAgent = desktopUserAgent;
117 | }
118 | if(searchType==="desktopD"){
119 | stopSearch = true;
120 | }
121 | console.log("Stopped performing searches.");
122 | return;
123 | }
124 |
125 | if (prevSearches.includes(searchTerm)) {
126 | console.log("Skipping duplicate search term: " + searchTerm);
127 | continue;
128 | }
129 | prevSearches.push(searchTerm);
130 |
131 | var url = searchUrl + encodeURIComponent(searchTerm) + "&cvid=83a6c35273834d10b4d9ef916d6c76f0&aqs=edge..69i57.1397j0j4&FORM=ANAB01&PC=U531";
132 |
133 | // if (activeTabId) {
134 | // await new Promise((resolve) => {
135 | // chrome.tabs.update(activeTabId, { url: url }, function (tab) {
136 | // console.log("Searching for: " + searchTerm + " in " + searchType);
137 | // resolve();
138 | // });
139 | // });
140 | // }
141 | if (activeTabId) {
142 | await randomTimeB();
143 | await delay(randomTime);
144 | // Update tab URL
145 | chrome.tabs.update(activeTabId, { url: url }, async function (tab) {
146 | console.log("Searching for: " + searchTerm + " in " + searchType);
147 | // Wait for the tab to be fully loaded
148 | await new Promise((resolve) => {
149 | // Listen for tab load completion
150 | chrome.tabs.onUpdated.addListener(function onTabUpdated(tabId, changeInfo) {
151 | console.log("Tab Id: " + tabId);
152 | if (tabId === activeTabId && changeInfo.status === "complete") {
153 | // Website is fully loaded, resolve the promise
154 | console.log("Website is fully loaded.");
155 | chrome.tabs.onUpdated.removeListener(onTabUpdated);
156 | resolve();
157 | }
158 | });
159 | });
160 | console.log("kati time execute yo");
161 | // Perform another search or further actions
162 | // actualSearch(numSearchesD, numSearchesM, searchType, searchGen);
163 | });
164 |
165 | }else {
166 | chrome.runtime.sendMessage({
167 | type: "start-searches",
168 | numSearchesD: numSearchesD,
169 | numSearchesM: numSearchesM,
170 | searchType: searchType,
171 | searchGen: searchGen,
172 | });
173 | }
174 | if(searchCount >= numSearches){
175 | chrome.storage.sync.set({ isSearching: false });
176 | result="";
177 | userAgent = desktopUserAgent;
178 | clearInterval(intervalId);
179 | if (searchType === "mobile"||searchType==="mobileM") {
180 | userAgent = desktopUserAgent;
181 | }
182 | console.log("Finished performing searches.");
183 | return;
184 | }
185 | searchCount++;
186 | await delay(1000);
187 | }
188 | }
189 | async function generateString(numSearches) {
190 | return new Promise((resolve) => {
191 | setTimeout(() => {
192 | var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
193 | var charactersLength = characters.length;
194 | if (result === "") {
195 | for (var i = 0; i < numSearches; i++) {
196 | result += characters.charAt(Math.floor(Math.random() * charactersLength));
197 | }
198 | } else {
199 | result = result.slice(0, -1);
200 | }
201 | resolve(result);
202 | }, 0);
203 | });
204 | }
205 |
206 | async function generateSearchTerm() {
207 | return new Promise((resolve) => {
208 | setTimeout(() => {
209 |
210 | var adjectives = [
211 | "famous",
212 | "delicious",
213 | "scary",
214 | "fantastic",
215 | "beautiful",
216 | "silly",
217 | "colorful",
218 | "exciting",
219 | "amazing",
220 | "weird",
221 | "abrupt",
222 | "adorable",
223 | "amiable",
224 | "awkward",
225 | "bizarre",
226 | "blushing",
227 | "brisk",
228 | "calm",
229 | "charming",
230 | "cheerful",
231 | "clumsy",
232 | "cooperative",
233 | "courageous",
234 | "creative",
235 | "cute",
236 | "delightful",
237 | "determined",
238 | "diligent",
239 | "elegant",
240 | "enthusiastic",
241 | "fabulous",
242 | "friendly",
243 | "funny",
244 | "gentle",
245 | "glamorous",
246 | "gorgeous",
247 | "graceful",
248 | "hilarious",
249 | "humble",
250 | "innocent",
251 | "intelligent",
252 | "jolly",
253 | "kind-hearted",
254 | "lively",
255 | "lovely",
256 | "lucky",
257 | "magnificent",
258 | "mysterious",
259 | "naughty",
260 | "happy",
261 | "embarrassing",
262 | "tall",
263 | "uncomfortable",
264 | "suspicious",
265 | "goofy",
266 | "cowardly",
267 | "brave",
268 | "groovy",
269 | "abrupt"
270 | ];
271 | var nouns = [
272 | "dog",
273 | "cat",
274 | "robot",
275 | "unicorn",
276 | "dragon",
277 | "spaceship",
278 | "planet",
279 | "piano",
280 | "jungle",
281 | "mountain",
282 | "apple",
283 | "banana",
284 | "book",
285 | "bottle",
286 | "car",
287 | "chair",
288 | "cloud",
289 | "coffee",
290 | "computer",
291 | "cup",
292 | "desk",
293 | "door",
294 | "flower",
295 | "guitar",
296 | "hat",
297 | "house",
298 | "jacket",
299 | "key",
300 | "lamp",
301 | "leaf",
302 | "lightning",
303 | "moon",
304 | "motorcycle",
305 | "ocean",
306 | "painting",
307 | "phone",
308 | "pillow",
309 | "rain",
310 | "river",
311 | "shoe",
312 | "sky",
313 | "snowflake",
314 | "star",
315 | "sunflower",
316 | "table",
317 | "tree",
318 | "umbrella",
319 | "window",
320 | "tulu",
321 | "ron",
322 | "sagar",
323 | "bipin",
324 | "lee",
325 | "jadu",
326 | "game",
327 | "valo",
328 | "rohan",
329 | "tulasha",
330 | "rito",
331 | "video"
332 | ];
333 |
334 | var adjIndex = Math.floor(Math.random() * adjectives.length);
335 | var nounIndex = Math.floor(Math.random() * nouns.length);
336 |
337 | resolve(adjectives[adjIndex] + " " + nouns[nounIndex]);
338 | }, 0);
339 | });
340 | }
341 | var tabId=null;
342 | chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
343 |
344 | if (message.type === "start-searches") {
345 | chrome.storage.sync.get("isSearching", function (data) {
346 | console.log("TESTING isSEARCHING"+data.isSearching);
347 | });
348 |
349 | chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
350 | if (tabs.length > 0) {
351 | activeTabId = tabs[0].id; // Store the tab ID of the active tab
352 | // performSearches(message.numSearches, message.searchType, message.searchGen);
353 | } else {
354 | chrome.storage.sync.set({ isSearching: false });
355 | console.error("No active tab found.");
356 |
357 | }
358 | });
359 | stopSearch=false;
360 | modeSearch(message.numSearchesD,message.numSearchesM, message.searchType, message.searchGen);
361 | } else if (message.type === "stop-searches") {
362 | chrome.storage.sync.set({ isSearching: false });
363 | stopSearch = true;
364 | searchCount=0;
365 | userAgent = desktopUserAgent;
366 | clearInterval(intervalId);
367 | result="";
368 | console.log("Stopped performing searches.");
369 | }
370 | });
371 |
372 | // add webRequest listener at the end of the file
373 | chrome.webRequest.onBeforeSendHeaders.addListener(
374 | function(details) {
375 | for (var i = 0; i < details.requestHeaders.length; ++i) {
376 | if (details.requestHeaders[i].name === 'User-Agent') {
377 | details.requestHeaders[i].value = userAgent;
378 | break;
379 | }
380 | }
381 | return {requestHeaders: details.requestHeaders};
382 | },
383 | {urls:
384 | [""]},
385 | ["blocking", "requestHeaders"]);
386 |
--------------------------------------------------------------------------------