Twitter Sensitive Content Viewer

Simple script to automatically click "Show" on tweets hidden behind the sensitive content warning on Twitter.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Twitter Sensitive Content Viewer
// @namespace    [email protected]
// @version      1.1.1.5
// @description  Simple script to automatically click "Show" on tweets hidden behind the sensitive content warning on Twitter.
// @author       omfgmule
// @match        *://twitter.com/*

// ==/UserScript==

(function() {
    'use strict';

    // If this script is helpful to you please consider simply retweeting so more people can use it!
    // https://x.com/omfgmule/status/1777623521427894569

    //Supported languages, if you need languages added feel free to contact me at @omfgmule on twitter or post a comment on the greasefork page
    const supportedLanguages = {
        EN: "Show",
        JP: "表示",
        ES: "Mostrar",
		CNS: "显示",
        CNT: "顯示",
        PL: "Pokaż",
        DE: "Anzeigen",
        TH: "แสดง"
    };

    const supportedRemoveButtonLanguages = {
        EN: "Hide",
        JP: "非表示にする",
        ES: "Ocultar",
		CNS: "隐藏",
        CNT: "隱藏",
        PL: "Ukryj",
        DE: "Ausblenden",
        TH: "ซ่อน"
    };

    window.addEventListener('load', function() {
        const revealSensitiveContent = () => {
            const currentUrl = window.location.href;
            if (!currentUrl.includes('/settings/')) {
                document.querySelectorAll('span.css-1qaijid.r-bcqeeo.r-qvutc0').forEach(span => {
                    const foundSupportedLanguage = Object.values(supportedLanguages).includes(span.textContent);
                    if (foundSupportedLanguage) {
                        let clickedAlready = false;
                        let target = span.parentNode;
                        if (target && target.click && !clickedAlready) {
                            target.click();
                            clickedAlready = true;
                        }
                        target = span.parentNode.parentNode
                            if (target && target.click && !clickedAlready) {
                                target.click();
                            }
                    }

                });
            }
        };

        const removeHideButton = () => {
            const currentUrl = window.location.href;
            if (!currentUrl.includes('/settings/')) {
                document.querySelectorAll('span.css-1qaijid.r-bcqeeo.r-qvutc0').forEach(span => {
                    let foundSupportedRemoveButtonLanguage = Object.values(supportedRemoveButtonLanguages).includes(span.textContent);
                    if (foundSupportedRemoveButtonLanguage) {
                        let thirdParentNode = span.parentNode.parentNode.parentNode;
                        if (thirdParentNode.className.includes('css-175oi2r r-sdzlij r-1phboty r-rs99b7 r-lrvibr')) {
                            thirdParentNode.remove();
                        }
                    }

                });
            }
        };

        revealSensitiveContent();
        removeHideButton();
        setInterval(revealSensitiveContent, 100);
        setInterval(removeHideButton, 100);
    });
})();