禁用知乎外链跳转提示

移除网页版知乎的 "即将离开知乎" 外链跳转提示

  1. // ==UserScript==
  2. // @name Zhihu Link Replacer
  3. // @name:zh-CN 禁用知乎外链跳转提示
  4. // @version 0.3
  5. // @description Remove 'leaving zhihu' prompt when accessing external link
  6. // @description:zh-CN 移除网页版知乎的 "即将离开知乎" 外链跳转提示
  7. // @author ReekyStive
  8. // @match *://*.zhihu.com/*
  9. // @icon https://static.zhihu.com/heifetz/favicon.ico
  10. // @grant none
  11. // @license MIT
  12. // @namespace http://reeky.org/
  13. // ==/UserScript==
  14.  
  15. (function () {
  16. 'use strict';
  17.  
  18. const replace = function () {
  19. console.log('[Zhihu Link Replacer] Replacing...');
  20. const links = document.querySelectorAll('.external, .LinkCard');
  21. let count = 0;
  22. for (let item of links) {
  23. const link = item.getAttribute('href');
  24. const matcher = /.*?link\.zhihu\.com\/\?target=/i;
  25. const originalLink = decodeURIComponent(link.replace(matcher, ''));
  26. if (link !== originalLink) {
  27. console.log('[Zhihu Link Replacer] Replaced ' + originalLink);
  28. count += 1;
  29. }
  30. item.setAttribute('href', originalLink);
  31. }
  32. console.log(`[Zhihu Link Replacer] Replaced ${count} links`);
  33. };
  34.  
  35. const intervalId = setInterval(() => { replace(); }, 3000);
  36. setTimeout(() => {
  37. clearInterval(intervalId);
  38. console.log(`[Zhihu Link Replacer] Stopped replace task`);
  39. }, 60000);
  40. })();

QingJ © 2025

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