Google搜索、Github、YouTube点击链接打开新的标签页

Google搜索、Github、YouTube点击链接时,在新的标签页打开链接网站

  1. // ==UserScript==
  2. // @name Google搜索、Github、YouTube点击链接打开新的标签页
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Google搜索、Github、YouTube点击链接时,在新的标签页打开链接网站
  6. // @author wxb
  7. // @include https://www.google.com/search?*
  8. // @include https://github.com/*
  9. // @include https://www.youtube.com/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. // 是不是YouTube网站
  16. let isYouTube = location.origin === 'https://www.youtube.com';
  17. let arr = Array.from(document.getElementsByTagName("a"));
  18. arr.forEach(item=>{
  19. item.setAttribute("target","_blank");
  20. if(isYouTube){
  21. item.onclick = (e)=>{
  22. window.open(`${item.href}`);
  23. e.stopPropagation();
  24. }
  25. }
  26.  
  27. })
  28. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址