Twitter Sensitive Content Viewer

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

目前為 2024-04-09 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Twitter Sensitive Content Viewer
// @namespace    [email protected]
// @version      1.1.1
// @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';

    //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"
    };

    const supportedRemoveButtonLanguages = {
        EN: "Hide",
        JP: "非表示にする",
        ES: "Ocultar"
    };

    window.addEventListener('load', function() {
        const revealSensitiveContent = () => {
            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 = () => {
            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);
    });
})();