google_highlight

Google検索結果でwikipediaは優良サイトなので目立つようにする。

  1. // ==UserScript==
  2. // @name google_highlight
  3. // @namespace https://catherine.v0cyc1pp.com/
  4. // @match https://www.google.co.jp/search?*
  5. // @match https://www.google.com/search?*
  6. // @author greg10
  7. // @run-at document-end
  8. // @license GPL 3.0
  9. // @version 0.1
  10. // @grant none
  11. // @description Google検索結果でwikipediaは優良サイトなので目立つようにする。
  12. // ==/UserScript==
  13.  
  14. console.log("google_highlight start");
  15.  
  16.  
  17. function sub() {
  18.  
  19. // URL行
  20. document.querySelectorAll("cite").forEach(function(elem) {
  21. var parent4 = elem.parentNode.parentNode.parentNode.parentNode;
  22. //console.log("parent4=" + parent4);
  23. if ( parent == null ) {
  24. return;
  25. }
  26.  
  27. var tagname = parent4.tagName;
  28. //console.log("tagname=" + tagname);
  29. if ( tagname != "A" ) {
  30. return;
  31. }
  32.  
  33. var href = parent4.href;
  34. if (href == "") return;
  35.  
  36. if ( href.indexOf("wikipedia.org") == -1 ) return;
  37.  
  38. elem.style.color = "#007f00";
  39. elem.style.backgroundColor = "#eeeeee";
  40.  
  41.  
  42. // 子のspanも色変える。2023.3.5
  43. elem.querySelectorAll("span").forEach(function(magospan) {
  44. magospan.style.color = "#007f00";
  45. magospan.style.backgroundColor = "#eeeeee";
  46. });
  47.  
  48. });
  49.  
  50. }
  51.  
  52. function main() {
  53. sub();
  54. }
  55.  
  56.  
  57. main();
  58.  
  59.