Remove Zhida Link and ZDI--FourPointedStar at Zhihu Site

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

// ==UserScript==
// @name              隐藏知乎网页中的知乎直答外链
// @name:en           Remove Zhida Link and ZDI--FourPointedStar at Zhihu Site
// @description       隐藏知乎网页中的知乎直答外链,并且去掉✦角标
// @description:en    Replace specific links with text-only spans, remove ✦ superscript, too.
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAFo0lEQVR4nJWXT4hlVxHGf9/tJyYuzJtxIziQN8RBFDEtIWB0MW+Mi4CIk4UuAtqvAxPcqAkJRNxMshDUTc8s3TjdO3c9QbIKod+o4CIuZtRFDEi3EIgEM/02jpPIPZ+LqnPv6TeB4IHLPfeeP1X11VdV54i2vewtOhaITcQDdEgdthAdINAGNkgd0IEVbwR17rAmx1TniSVil6e0V0UKgJc8pWdfG5yvwqRhs1FQIyQ3trvcpxsVGd4xf/gelO24yV0usK1VB6APOMDMKSADBShIBWNwj1WwjClAzLEL0CMc86jj9cl/LgRs8ZjCJvexH5r/xAuJa260TatG6DosIee4lHO0ZnWDXH5bgYQ8uql122Iis2Xnj4JtRH675AIHMAQKuAsdrLV3dYXTwQ7Bir1jrzJ+Wyw698yVkLmgxgVg+PGjcPw8zD6JKcgFUcD94AoNa0eXkO600lVqXOPqPrPZNT6tjylYBRZfgp0n4GgFR7dDkEieeNys6ZPCBq4MCicXdFLWdIKBHtMFfC4JY8Hf/nxEyY0jmD+IM7Cgy77gxtto+jF4+NMj8+tY84YOLd8JnZJPpiDxI7shUigimJ2Gwxf5yLb9aryvffOj5+pXKbzJDxOVoIw7REkLhedno7+6CzffgdkpmE3z+5/Nrq7JJMfejc3bNj+TnT4tTyRtmLiAlARKliK09Uis2fsTPPcqvvwNdPlxuP4mbO+P4aQObz0cG958F77+mxMJh9kDcPh0IpCcUIerqycYuc8FGX7zczB/CI6O4cofAA9GjuRjUFhN2I0hmISlNFCUzCGMSkxqfFJw3XD6cXj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xROM//g0ZbQrKXVza0EQcQiWNvcIuOXXbG6/n/AAwhLDO9HaqBAAAAAElFTkSuQmCC
// @namespace    http://tampermonkey.net/
// @version      1.0.5
// @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

})();