Twitter Show Sensitive Media

Show sensitive media

// ==UserScript==
// @name            	Twitter Show Sensitive Media
// @namespace       	https://greasyfork.org/users/821661
// @match           	https://twitter.com/*
// @match           	https://x.com/*
// @grant           	none
// @version         	1.6
// @icon                https://www.google.com/s2/favicons?domain=x.com
// @run-at              document-start
// @author          	hdyzen
// @description     	Show sensitive media
// @license         	MIT
// ==/UserScript==
'use strict';

// Store original XHR open
const originalXHR = XMLHttpRequest.prototype.open;

// Monkey patch XHR open
XMLHttpRequest.prototype.open = function (method, url, async, user, password) {
    // Test url
    if (/\/(?:User|TweetDetail|Adaptive)/.test(url)) {
        this.addEventListener('readystatechange', function (e) {
            if (this.readyState === 4) {
                const responseMod = e.target.responseText.replace(/possibly_sensitive|adult_content|sensitive_media|mediaVisibilityResults/gim, '');
                Object.defineProperties(this, {
                    response: { value: responseMod, writable: true },
                    responseText: { value: responseMod, writable: true },
                });
            }
        });
    }
    return originalXHR.apply(this, arguments);
};