屏蔽知乎直答标记

替换知乎网页端回答和文章中类似"知乎直答✦"的关键词为普通搜索超链接,并去掉✦角标。关联:关闭知乎直达。

  1. // ==UserScript==
  2. // @name 屏蔽知乎直答标记
  3. // @namespace https://github.com/Okukozome/fuck-Zhihu-Zhida
  4. // @version 1.0
  5. // @description 替换知乎网页端回答和文章中类似"知乎直答✦"的关键词为普通搜索超链接,并去掉✦角标。关联:关闭知乎直达。
  6. // @author Okukozome
  7. // @match *://*.zhihu.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. const targetClass = "RichContent-EntityWord";
  16.  
  17. // 处理并替换链接
  18. function replaceLinks() {
  19. const links = document.querySelectorAll(`a.${targetClass}`);
  20. links.forEach(link => {
  21. if (link.dataset.modified) return; // 跳过已处理的链接
  22. let keyword = link.textContent;
  23. if (keyword) {
  24. let newUrl = `https://www.zhihu.com/search?type=content&q=${encodeURIComponent(keyword)}`;
  25. link.href = newUrl;
  26. link.innerHTML = keyword; // 移除任何图标
  27. link.dataset.modified = "true"; // 标记为已修改
  28. }
  29. });
  30. }
  31.  
  32. // 页面加载时初次调用以替换链接
  33. replaceLinks();
  34.  
  35. // 设置一个MutationObserver监视document.body的变化,处理动态添加的内容
  36. const observer = new MutationObserver(replaceLinks);
  37. observer.observe(document.body, { childList: true, subtree: true });
  38. })();

QingJ © 2025

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