Greasy Fork

Greasy Fork is available in English.

Show Censored Media

Modifies the CSS classes to automatically show all censored media in desktop mode and adjusts specific elements based on class.

当前为 2024-04-10 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Show Censored Media
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Modifies the CSS classes to automatically show all censored media in desktop mode and adjusts specific elements based on class.
// @author       Xaikyre
// @match        https://twitter.com/*
// @match        https://x.com/*
// @license MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to modify classes of children for specific parent divs
    function modifyChildClasses() {
        const parentDivs = document.querySelectorAll('.css-175oi2r.r-18u37iz.r-9aw3ui.r-4amgru.r-14gqq1x');
        parentDivs.forEach(parentDiv => {
            const children = parentDiv.querySelectorAll('.css-175oi2r.r-1udh08x, .css-175oi2r.r-yfv4eo');
            children.forEach(child => {
                child.className = 'css-175oi2r r-1adg3ll r-1ny4l3l';
            });
        });
    }

    // Function to remove specific divs by a complex class string
    function removeSpecificDivs() {
        const elements = document.querySelectorAll('.css-175oi2r.r-1awozwy.r-1p0dtai.r-zchlnj.r-1cmwbt1.r-1777fci.r-edyy15.r-u8s1d.r-1d2f490.r-ipm5af');
        elements.forEach(element => element.remove());
    }

    // Additional modifications based on new requirements
    function additionalModifications() {
        const targetParentDivs = document.querySelectorAll('.css-175oi2r');
        targetParentDivs.forEach(parentDiv => {
            // Modify specific child div classes
            const modifiableDivs = parentDiv.querySelectorAll('.css-175oi2r.r-l3hqri.r-1udh08x.r-1867qdf.r-16y2uox, .css-175oi2r.r-yfv4eo.r-16y2uox');
            modifiableDivs.forEach(div => {
                if (div.classList.contains('r-l3hqri')) {
                    div.className = 'css-175oi2r r-1867qdf r-16y2uox';
                } else if (div.classList.contains('r-yfv4eo')) {
                    div.className = 'css-175oi2r r-16y2uox';
                }
            });
            // Remove specific div
            const removableDivs = parentDiv.querySelectorAll('.css-175oi2r.r-drfeu3.r-1p0dtai.r-eqz5dr.r-16y2uox.r-1777fci.r-1d2f490.r-ymttw5.r-1f1sjgu.r-u8s1d.r-zchlnj.r-ipm5af.r-1867qdf');
            removableDivs.forEach(div => div.remove());
        });
    }

    // MutationObserver for dynamic content handling
    const observer = new MutationObserver(mutations => {
        mutations.forEach(() => {
            modifyChildClasses();
            removeSpecificDivs();
            additionalModifications();
        });
    });

    const config = { childList: true, subtree: true };
    observer.observe(document.body, config);

    // Initial call to functions
    modifyChildClasses();
    removeSpecificDivs();
    additionalModifications();
})();