Google 谷歌搜索结果以新标签页打开

将谷歌搜索结果的链接修改为以新标签页打开

当前为 2020-02-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Open Google Search Results in New Tab
  3. // @name:zh-CN Google 谷歌搜索结果以新标签页打开
  4. // @namespace https://github.com/zkqiang
  5. // @version 1.0
  6. // @description Modify the Google search results link to open in a new tab
  7. // @description:zh-CN 将谷歌搜索结果的链接修改为以新标签页打开
  8. // @author zkqiang
  9. // @match *://www.google.com/search?*
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. 'use strict';
  16.  
  17. function modify(element) {
  18. try {
  19. var links = element.getElementsByTagName('a');
  20. for (var i = 0; i < links.length; i++) {
  21. links[i].target = '_blank';
  22. }
  23. } catch (err) {
  24. }
  25. }
  26.  
  27. modify(document.getElementById('res'));
  28. modify(document.getElementById('bottomads'));
  29. modify(document.getElementById('rhs'));
  30. modify(document.getElementById('fsl'));
  31. })();