Hide unfollowed replies (Twitter/X)

hide unfollowed replies in twitter/X

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name                Hide unfollowed replies (Twitter/X)
// @namespace           https://greasyfork.org/users/821661
// @match               https://x.com/*
// @grant               none
// @version             1.0
// @author              hdyzen
// @description         hide unfollowed replies in twitter/X
// @license             GPL-3.0-only
// ==/UserScript==

const originalJParse = JSON.parse;

JSON.parse = function (text, reviver) {
    const result = originalJParse.call(this, text, reviver);
    if (text.includes('"following":')) {
        const entries = result?.data?.threaded_conversation_with_injections_v2?.instructions?.[0]?.entries;

        if (!entries) return result;

        for (const entry of entries) {
            const replies = entry?.content?.items;

            if (!replies) continue;

            entry.content.items = replies.filter(e => e.item?.itemContent?.tweet_results?.result?.core?.user_results?.result?.legacy?.following);
        }
    }

    return result;
};