Google_HightLight

对Google搜索结果进行高亮

  1. // ==UserScript==
  2. // @name Google_HightLight
  3. // @namespace http://tampermonkey.net
  4. // @run-at document-body
  5. // @version 1.3
  6. // @description 对Google搜索结果进行高亮
  7. // @author cweijan
  8. // @include https://www.google.co*/search*
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. var keyWords = document.getElementById("lst-ib").value;
  13. var searchList = document.querySelectorAll(".g,.r,a");
  14. searchList.forEach(function(index) {
  15. var text =index.innerHTML;
  16. for (var i = 0; i < keyWords.length; i++) {
  17. var keyWord = keyWords.charAt(i);
  18. if(keyWord.charCodeAt()<128){
  19. continue;
  20. }
  21. text = text.replace(new RegExp(keyWord,'g'), "<em>" + keyWord + "</em>");
  22. }
  23. index.innerHTML=text;
  24. });
  25. })();
  26.