google_hide_results2

Hide results on Google search results.

  1. // ==UserScript==
  2. // @name google_hide_results2
  3. // @namespace http://catherine.v0cyc1pp.com/google_hide_results2.user.js
  4. // @include https://www.google.co.jp/search*
  5. // @include https://www.google.com/search*
  6. // @author greg10
  7. // @run-at document-start
  8. // @license GPL 3.0
  9. // @version 2.0
  10. // @grant none
  11. // @description Hide results on Google search results.
  12. // ==/UserScript==
  13.  
  14.  
  15. //================================
  16. // Configurations
  17. // - specify texts you don't want to see.
  18. var g_list = [
  19. "malicious-site.com",
  20. "/youdontwantsee*",
  21. ];
  22. //================================
  23.  
  24.  
  25.  
  26. function main() {
  27. //$("h3 > a").each(function() {
  28. document.querySelectorAll("div.g").forEach(function(elem){
  29. //var str = $(this).attr("href");
  30. var str = elem.innerText;
  31. //console.log("str="+str);
  32.  
  33. for ( var i = 0; i < g_list.length; ++i) {
  34. var ngword = g_list[i];
  35. if ( ngword == "" ) continue;
  36.  
  37. ngword = ngword.replace(/^\s+|\s+$/g, "");
  38. var encoded_str = encodeURI( ngword );
  39.  
  40. var obj = new RegExp( ngword, "i");
  41. var ret1 = str.search( RegExp( ngword, "i") );
  42. var ret2 = str.search( RegExp( encoded_str, "i") );
  43. //var index = str.indexOf( ngword );
  44. if ( ret1 != -1 || ret2 != -1) {
  45. //$(this).parent("h3").parent("div").parent("div").hide();
  46. elem.style.display = "none";
  47. }
  48. }
  49. });
  50. }
  51.  
  52. var observer = new MutationObserver(function(mutations) {
  53. observer.disconnect();
  54. main();
  55. observer.observe( document, config);
  56. });
  57.  
  58. //var config = { attributes: true, childList: true, characterData: true, subtree:true }
  59. var config = { childList: true, characterData: true, subtree:true };
  60.  
  61. observer.observe( document, config);