Google Search: Remove AI Results

Appends Google Search queries with a string of phrases designed to exclude webpages that use AI, without you manually having to append arguments. If you want to stop these arguments getting added, add an underscore as the last character of your search query.

  1. // ==UserScript==
  2. // @name Google Search: Remove AI Results
  3. // @namespace https://sinisterpixel.tv
  4. // @version 1.1
  5. // @description Appends Google Search queries with a string of phrases designed to exclude webpages that use AI, without you manually having to append arguments. If you want to stop these arguments getting added, add an underscore as the last character of your search query.
  6. // @author Sinister Pixel
  7. // @match https://www.google.com/search*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Phrases to append to the search query
  16. const appendPhrases = "-\"stable diffusion\" -\"ai\" -\"midjourney\" -\"open art\" -\"prompt hunt\"";
  17. const flagParam = 'modified'; // Flag to prevent infinite redirection
  18.  
  19. // Get the current URL parameters
  20. const urlParams = new URLSearchParams(window.location.search);
  21.  
  22. // Check if the script has already modified the query
  23. if (urlParams.has(flagParam)) {
  24. return; // Exit if already modified
  25. }
  26.  
  27. const query = urlParams.get('q');
  28.  
  29. // Check if the query exists, does not end with an underscore, and does not already include the appended phrases
  30. if (query && query.slice(-1) !== "_" && !query.includes(appendPhrases)) {
  31. // Append the phrases
  32. const modifiedQuery = `${query} ${appendPhrases}`;
  33.  
  34. // Update the search query parameter
  35. urlParams.set('q', modifiedQuery);
  36.  
  37. // Add the flag parameter to prevent infinite redirection
  38. urlParams.set(flagParam, 'true');
  39.  
  40. // Redirect to the modified URL
  41. const newUrl = `${window.location.pathname}?${urlParams.toString()}`;
  42. window.location.replace(newUrl);
  43. }
  44. })();