├── README.md ├── background.js ├── content.js ├── icons └── no-internet.png └── manifest.json /README.md: -------------------------------------------------------------------------------- 1 | ## Installation 2 | 3 | 1. Clone or download the repository: 4 | ```bash 5 | git clone https://github.com/husseinphp/Hide-Search-Result 6 | 2- Open Google Chrome and navigate to chrome://extensions/. 7 | 8 | 3- Enable Developer Mode by toggling the switch in the top-right corner. 9 | 10 | 4- Click on the Load unpacked button. 11 | 12 | 5- Select the folder where you cloned or unzipped this repository. 13 | 14 | The extension will now be loaded and ready to use. 15 | -------------------------------------------------------------------------------- /background.js: -------------------------------------------------------------------------------- 1 | chrome.runtime.onInstalled.addListener(() => { 2 | chrome.contextMenus.create({ 3 | id: "hideLink", 4 | title: "Hide 📥", 5 | contexts: ["link"] 6 | }); 7 | }); 8 | 9 | chrome.contextMenus.onClicked.addListener((info, tab) => { 10 | if (info.menuItemId === "hideLink") { 11 | const urlToExclude = new URL(info.linkUrl).hostname; 12 | 13 | chrome.storage.sync.get("excludedUrls", (data) => { 14 | let excludedUrls = data.excludedUrls || []; 15 | 16 | // Check if the result is already excluded 17 | if (!excludedUrls.includes(urlToExclude)) { 18 | excludedUrls.push(urlToExclude); 19 | } 20 | 21 | // Remove duplicate links 22 | excludedUrls = [...new Set(excludedUrls)]; 23 | 24 | // Update storage with excluded links 25 | chrome.storage.sync.set({ excludedUrls: excludedUrls }, () => { 26 | chrome.tabs.get(tab.id, (currentTab) => { 27 | const url = new URL(currentTab.url); 28 | 29 | if (url.searchParams.has("q")) { 30 | let query = url.searchParams.get("q"); 31 | 32 | // Extract the site from the search query 33 | const siteMatch = query.match(/site:([^\s]+)/); 34 | const searchSite = siteMatch ? siteMatch[1] : ''; // If not found, it will be empty 35 | 36 | // Ensure site:searchSite is added if it exists 37 | if (searchSite && !query.includes(`site:${searchSite}`)) { 38 | query = `site:${searchSite} ${query}`; 39 | } 40 | 41 | // Add all excluded links to the query without duplication 42 | excludedUrls.forEach(excludedUrl => { 43 | if (!query.includes(`-site:${excludedUrl}`)) { 44 | query += ` -site:${excludedUrl}`; 45 | } 46 | }); 47 | 48 | // Update the search query 49 | url.searchParams.set("q", query.trim()); // Use trim to remove excess spaces 50 | chrome.tabs.update(tab.id, { url: url.toString() }); 51 | } 52 | }); 53 | }); 54 | }); 55 | } 56 | }); 57 | 58 | // Use onUpdated to monitor search pages 59 | chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { 60 | if (changeInfo.status === 'complete' && tab.url.includes("google.com/search?q=")) { 61 | // Do not reset the excluded links list when a new search page loads 62 | } 63 | }); 64 | -------------------------------------------------------------------------------- /content.js: -------------------------------------------------------------------------------- 1 | // Function to create a button with specified properties 2 | function createButton(text, color, onClick) { 3 | const button = document.createElement('button'); 4 | button.innerText = text; 5 | button.style.width = '100%'; // Make buttons take the full width of the menu 6 | button.style.margin = '5px 0'; // Space between buttons 7 | button.style.padding = '10px'; 8 | button.style.backgroundColor = color; 9 | button.style.color = 'white'; 10 | button.style.border = 'none'; 11 | button.style.borderRadius = '5px'; 12 | button.style.cursor = 'pointer'; 13 | button.addEventListener('click', onClick); 14 | return button; 15 | } 16 | 17 | // Create the dropdown menu button 18 | const dropdownButton = document.createElement('button'); 19 | dropdownButton.innerText = ' Search Options'; 20 | dropdownButton.style.position = 'fixed'; 21 | dropdownButton.style.top = '10px'; 22 | dropdownButton.style.right = '10px'; 23 | dropdownButton.style.zIndex = '1000'; 24 | dropdownButton.style.padding = '10px'; 25 | dropdownButton.style.backgroundColor = '#3498DB'; // Main button color 26 | dropdownButton.style.color = 'white'; 27 | dropdownButton.style.border = 'none'; 28 | dropdownButton.style.borderRadius = '5px'; 29 | dropdownButton.style.cursor = 'pointer'; 30 | document.body.appendChild(dropdownButton); 31 | 32 | // Create the dropdown menu 33 | const dropdownMenu = document.createElement('div'); 34 | dropdownMenu.style.position = 'fixed'; 35 | dropdownMenu.style.top = '50px'; 36 | dropdownMenu.style.right = '10px'; 37 | dropdownMenu.style.zIndex = '1000'; 38 | dropdownMenu.style.backgroundColor = 'white'; 39 | dropdownMenu.style.border = '1px solid #ddd'; 40 | dropdownMenu.style.borderRadius = '5px'; 41 | dropdownMenu.style.padding = '10px'; 42 | dropdownMenu.style.boxShadow = '0 2px 10px rgba(0,0,0,0.1)'; 43 | dropdownMenu.style.width = '11%'; 44 | dropdownMenu.style.display = 'none'; // Hide menu initially 45 | document.body.appendChild(dropdownMenu); 46 | 47 | // Toggle menu display 48 | dropdownButton.addEventListener('click', () => { 49 | dropdownMenu.style.display = dropdownMenu.style.display === 'none' ? 'block' : 'none'; 50 | }); 51 | 52 | // Create buttons and add them to the dropdown menu 53 | dropdownMenu.appendChild(createButton('Reset Excluded Results', '#E74C3C', () => { 54 | chrome.storage.sync.set({ excludedUrls: [] }, () => { 55 | alert('Excluded results have been reset!'); 56 | }); 57 | })); 58 | dropdownMenu.appendChild(createButton('Add inurl to Search', '#2ECC71', () => { 59 | const query = new URL(window.location.href).searchParams.get("q"); 60 | const inurlQuery = `inurl:? || inurl:& ${query}`; 61 | const url = new URL(window.location.href); 62 | url.searchParams.set("q", inurlQuery); 63 | window.location.href = url.toString(); 64 | })); 65 | dropdownMenu.appendChild(createButton('Search Login/Register', '#3498DB', () => { 66 | const query = new URL(window.location.href).searchParams.get("q"); 67 | const loginQuery = `(intext:Login OR intext:Register OR intext:"Create Account") ${query}`; 68 | const url = new URL(window.location.href); 69 | url.searchParams.set("q", loginQuery); 70 | window.location.href = url.toString(); 71 | })); 72 | dropdownMenu.appendChild(createButton('Search Signin/Register URLs', '#F39C12', () => { 73 | const query = new URL(window.location.href).searchParams.get("q"); 74 | const signinQuery = `(inurl:/signin OR inurl:/login OR inurl:/register) ${query}`; 75 | const url = new URL(window.location.href); 76 | url.searchParams.set("q", signinQuery); 77 | window.location.href = url.toString(); 78 | })); 79 | dropdownMenu.appendChild(createButton('Search PHP Files', '#8E44AD', () => { 80 | const query = new URL(window.location.href).searchParams.get("q"); 81 | const phpQuery = `filetype:php ${query}`; 82 | const url = new URL(window.location.href); 83 | url.searchParams.set("q", phpQuery); 84 | window.location.href = url.toString(); 85 | })); 86 | dropdownMenu.appendChild(createButton('Search PDF Files', '#D35400', () => { 87 | const query = new URL(window.location.href).searchParams.get("q"); 88 | const pdfQuery = `ext:pdf ${query}`; 89 | const url = new URL(window.location.href); 90 | url.searchParams.set("q", pdfQuery); 91 | window.location.href = url.toString(); 92 | })); 93 | dropdownMenu.appendChild(createButton('Search Invoices/Receipts', '#C0392B', () => { 94 | const query = new URL(window.location.href).searchParams.get("q"); 95 | const invoiceReceiptQuery = `"invoice" "receipt" ext:pdf ${query}`; 96 | const url = new URL(window.location.href); 97 | url.searchParams.set("q", invoiceReceiptQuery); 98 | window.location.href = url.toString(); 99 | })); 100 | dropdownMenu.appendChild(createButton('Search Before 2015', '#1ABC9C', () => { 101 | const query = new URL(window.location.href).searchParams.get("q"); 102 | const beforeQuery = `before:2015-01-01 ${query}`; 103 | const url = new URL(window.location.href); 104 | url.searchParams.set("q", beforeQuery); 105 | window.location.href = url.toString(); 106 | })); 107 | dropdownMenu.appendChild(createButton('Search PDF with Login Info', '#9B59B6', () => { 108 | const query = new URL(window.location.href).searchParams.get("q"); 109 | const loginInfoQuery = `(login: OR api OR password: OR pass:) ext:pdf ${query}`; 110 | const url = new URL(window.location.href); 111 | url.searchParams.set("q", loginInfoQuery); 112 | window.location.href = url.toString(); 113 | })); 114 | 115 | // Add "0xHussein" button 116 | dropdownMenu.appendChild(createButton('0xHussein', '#4CAF50', () => { 117 | window.open('https://x.com/0xHussein', '_blank'); // Open link in new window 118 | })); 119 | 120 | // Add "Clear Search" button 121 | dropdownMenu.appendChild(createButton('Clear Search', '#FF5733', () => { 122 | const currentUrl = new URL(window.location.href); 123 | const query = currentUrl.searchParams.get("q"); 124 | 125 | // Extract original domain from query 126 | const match = query.match(/site:([^\s]+)/); 127 | const originalDomain = match ? match[1] : ''; 128 | 129 | if (originalDomain) { 130 | // Create a new query with the original domain only 131 | const clearQuery = `site:${originalDomain}`; 132 | currentUrl.searchParams.set("q", clearQuery); // Update search query 133 | window.location.href = currentUrl.toString(); // Redirect to new URL 134 | } else { 135 | alert("No valid domain found in the search query!"); 136 | } 137 | })); 138 | -------------------------------------------------------------------------------- /icons/no-internet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/husseinphp/Hide-Search-Result/69eb9fb87a9a3a7ba8c418aa352665a6ef9c3373/icons/no-internet.png -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 3, 3 | "name": "Hide Search Result", 4 | "version": "1.0", 5 | "permissions": ["contextMenus", "storage", "activeTab", "scripting", "webNavigation"], 6 | "background": { 7 | "service_worker": "background.js" 8 | }, 9 | "content_scripts": [ 10 | { 11 | "matches": ["*://*/*"], 12 | "js": ["content.js"] 13 | } 14 | ], 15 | "host_permissions": ["*://*/*"], 16 | "icons": { 17 | "16": "icons/no-internet.png", 18 | "48": "icons/no-internet.png", 19 | "128": "icons/no-internet.png" 20 | }, 21 | "action": { 22 | "default_icon": { 23 | "16": "icons/no-internet.png", 24 | "48": "icons/no-internet.png", 25 | "128": "icons/no-internet.png" 26 | }, 27 | "default_title": "Hide Search Result" 28 | } 29 | } 30 | --------------------------------------------------------------------------------