Remove Zhida Link and ZDI--FourPointedStar at Zhihu Site

Replace specific links with text-only spans, remove ✦ superscript, too.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name              隐藏知乎网页中的知乎直答外链
// @name:en           Remove Zhida Link and ZDI--FourPointedStar at Zhihu Site
// @name:zh-TW        隱藏知乎網頁中的知乎直答外鏈
// @name:ja           知乎のウェブページ上の知乎直答の外部リンクを非表示
// @name:ko           Zhihu 웹 페이지의 Zhihu 직답 외부 링크 숨기기
// @name:fr           Masquer les liens externes de Zhihu Zhida sur le site de Zhihu
// @name:de           Externe Zhihu Zhida-Links auf der Zhihu-Website ausblenden
// @name:es           Ocultar enlaces externos de Zhihu Zhida en el sitio de Zhihu
// @name:ru           Скрыть внешние ссылки Zhihu Zhida на сайте Zhihu
// @name:ar           إخفاء روابط Zhihu Zhida الخارجية على موقع Zhihu
// @name:pt           Ocultar links externos do Zhihu Zhida no site do Zhihu
// @name:it           Nascondi i link esterni di Zhihu Zhida sul sito di Zhihu
// @description       隐藏知乎网页中的知乎直答外链,并且去掉✦角标
// @description:en    Replace specific links with text-only spans, remove ✦ superscript, too.
// @description:zh-TW 隱藏知乎網頁中的知乎直答外鏈,並且去掉✦角標
// @description:ja    知乎のウェブページ上の知乎直答の外部リンクを非表示にし、✦の上付き文字も削除
// @description:ko    Zhihu 웹 페이지의 Zhihu 직답 외부 링크를 숨기고 ✦ 위첨자도 제거
// @description:fr    Masquer les liens externes de Zhihu Zhida sur la page web de Zhihu et supprimer le symbole ✦ en exposant
// @description:de    Externe Zhihu Zhida-Links auf der Webseite ausblenden und das ✦-Hochgestellte entfernen
// @description:es    Ocultar enlaces externos de Zhihu Zhida en la página web y eliminar el subíndice ✦
// @description:ru    Скрыть внешние ссылки Zhihu Zhida на веб-странице и удалить надстрочный знак ✦
// @description:ar    إخفاء روابط Zhihu Zhida الخارجية على صفحة الويب وإزالة الرمز المرتفع ✦
// @description:pt    Ocultar links externos do Zhihu Zhida na página da web e remover o sobrescrito ✦
// @description:it    Nascondere i link esterni di Zhihu Zhida sulla pagina web e rimuovere il simbolo in apice ✦
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAFo0lEQVR4nJWXT4hlVxHGf9/tJyYuzJtxIziQN8RBFDEtIWB0MW+Mi4CIk4UuAtqvAxPcqAkJRNxMshDUTc8s3TjdO3c9QbIKod+o4CIuZtRFDEi3EIgEM/02jpPIPZ+LqnPv6TeB4IHLPfeeP1X11VdV54i2vewtOhaITcQDdEgdthAdINAGNkgd0IEVbwR17rAmx1TniSVil6e0V0UKgJc8pWdfG5yvwqRhs1FQIyQ3trvcpxsVGd4xf/gelO24yV0usK1VB6APOMDMKSADBShIBWNwj1WwjClAzLEL0CMc86jj9cl/LgRs8ZjCJvexH5r/xAuJa260TatG6DosIee4lHO0ZnWDXH5bgYQ8uql122Iis2Xnj4JtRH675AIHMAQKuAsdrLV3dYXTwQ7Bir1jrzJ+Wyw698yVkLmgxgVg+PGjcPw8zD6JKcgFUcD94AoNa0eXkO600lVqXOPqPrPZNT6tjylYBRZfgp0n4GgFR7dDkEieeNys6ZPCBq4MCicXdFLWdIKBHtMFfC4JY8Hf/nxEyY0jmD+IM7Cgy77gxtto+jF4+NMj8+tY84YOLd8JnZJPpiDxI7shUigimJ2Gwxf5yLb9aryvffOj5+pXKbzJDxOVoIw7REkLhedno7+6CzffgdkpmE3z+5/Nrq7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oEzWmyxIyw6zW6FRQ6c2NapC5pCjuAl5+Od7Tru41vxagEpTOeN0LAq7oe0lH0DeC6uVH0Lito03kbVUnmSrp+yE/967Y8dNfqEvdwD+L09a3BrgbqA/IZS4H4osLE3mHlDzYB30iUJ7XwwklrzPhXWk4ZIXdGxROM//g0ZbQrKXVza0EQcQiWNvcIuOXXbG6/n/AAwhLDO9HaqBAAAAAElFTkSuQmCC
// @namespace    http://tampermonkey.net/
// @version      1.0.6
// @author       aspen138
// @match        *://www.zhihu.com/*
// @grant        none
// @license      MIT
// ==/UserScript==


// test case:
// 有哪些历史上著名的合影? - 施耐泽的回答 - 知乎 https://www.zhihu.com/question/23674814/answer/25403040


(function() {
    'use strict';

    // Function to process both links and SVGs
    function processNode(node) {
        const links = node.querySelectorAll('a.RichContent-EntityWord');
        links.forEach(link => {
            if (link.dataset.modified) return; // Skip already processed links
            let keyword = link.textContent;
            if (keyword) {
                let newUrl = `https://www.zhihu.com/search?type=content&q=${encodeURIComponent(keyword)}`;
                link.href = newUrl;
                link.innerHTML = keyword; // Remove any icons
                link.dataset.modified = "true"; // Mark as modified
            }
        });
    }

    // Initial processing on page load
    processNode(document);

    // MutationObserver to detect and process newly added content
    const observer = new MutationObserver(() => {
        processNode(document);
    });

    // Start observing the document for child node changes
    observer.observe(document.body, { childList: true, subtree: true });

    // Set interval to process nodes every 15 seconds
    setInterval(() => {
        processNode(document);
    }, 15000); // 15000ms = 15 seconds

})();