Remove the AI summary from Google Search

Remove the "AI summary" results from Google Search

  1. // ==UserScript==
  2. // @name Remove the AI summary from Google Search
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-11-20
  5. // @description Remove the "AI summary" results from Google Search
  6. // @author jonbakerfish
  7. // @include https://www.google.com/search?*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // The following code is from: https://github.com/zbarnz/Google_AI_Overviews_Blocker
  17. const patterns = [
  18. /ai overview/i,
  19. /AI による概要/
  20. ]
  21.  
  22. const observer = new MutationObserver(() => {
  23. // each time there's a mutation in the document see if there's an ai overview to hide
  24. const aiOverviewH1 = [...document.querySelectorAll('h1')].find(h1 => patterns.some(pattern => pattern.test(h1.innerText)));
  25.  
  26. if(aiOverviewH1?.parentElement) {
  27. aiOverviewH1.parentElement.style.display = 'none';
  28. }
  29. });
  30.  
  31. observer.observe(document, {
  32. childList: true,
  33. subtree: true,
  34. });
  35.  
  36. })();