知乎真實鏈接地址重定向

讓知乎網頁中的站外鏈接直接跳轉至目標網址,而不經過壹個二次跳轉頁面。重定向處理將會在點擊鏈接瞬間自動觸發

  1. // ==UserScript==
  2. // @name Zhihu Link Redirect Fix
  3. // @name:zh-CN 知乎真实链接地址重定向
  4. // @name:zh-TW 知乎真實鏈接地址重定向
  5. // @description Avoid link redirect for zhihu.com
  6. // @description:zh-CN 让知乎网页中的站外链接直接跳转至目标网址,而不经过一个二次跳转页面。重定向处理将会在点击链接瞬间自动触发
  7. // @description:zh-TW 讓知乎網頁中的站外鏈接直接跳轉至目標網址,而不經過壹個二次跳轉頁面。重定向處理將會在點擊鏈接瞬間自動觸發
  8.  
  9. // @author Moshel
  10. // @namespace https://hzy.pw
  11. // @homepageURL https://hzy.pw/p/2056
  12. // @supportURL https://github.com/h2y/link-fix
  13. // @license GPL-3.0
  14. // @icon https://pic1.zhimg.com/2e33f063f1bd9221df967219167b5de0_m.jpg
  15.  
  16. // @grant none
  17. // @run-at document-start
  18. // @include *.zhihu.com/*
  19.  
  20. // @date 06/10/2016
  21. // @modified 05/22/2019
  22. // @version 1.3.2.7
  23. // ==/UserScript==
  24.  
  25.  
  26. if(location.host==='link.zhihu.com') {
  27. let regRet = location.search.match(/target=(.+?)(&|$)/);
  28. if(regRet && regRet.length==3)
  29. location.href = decodeURIComponent(regRet[1]);
  30. }
  31. else
  32. window.addEventListener('click', function(e){
  33. let dom = e.target,
  34. max_times = 5;
  35. while(dom && max_times--) {
  36. if(dom.nodeName.toUpperCase()==='A') {
  37. let regRet = dom.search.match(/target=(.+?)(&|$)/);
  38. if(regRet && regRet.length==3)
  39. dom.href = decodeURIComponent(regRet[1]);
  40. return;
  41. }
  42. else
  43. dom = dom.parentNode;
  44. }
  45. });

QingJ © 2025

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