您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Marks all media as sensitive. This could be used to avoid seeing unwanted NSFW content.
当前为
- // ==UserScript==
- // @name Twitter/X.com mark all media as sensitive
- // @namespace http://tampermonkey.net/
- // @version 1.0
- // @description Marks all media as sensitive. This could be used to avoid seeing unwanted NSFW content.
- // @author Azeez
- // @match https://*.twitter.com/*
- // @match https://*.x.com/*
- // @icon https://www.google.com/s2/favicons?domain=twitter.com
- // @license MIT
- // ==/UserScript==
- (function() {
- let findObjectsForKey = function(obj, keys) {
- return Object.entries(obj).reduce((found, [key, value]) => {
- if (keys.includes(key)) {
- found.push(value);
- }
- if (value != null && typeof(value) == 'object') {
- found = found.concat(findObjectsForKey(value, keys));
- }
- return found;
- }, []);
- };
- let blurMedia = function(data) {
- findObjectsForKey(data, ['media']).forEach(obj => {
- if (Array.isArray(obj)) {
- obj.forEach(media => {
- if (typeof media == 'object') {
- media.sensitive_media_warning = {other: true};
- }
- });
- }
- });
- };
- let old_parse = unsafeWindow.JSON.parse;
- let new_parse = function(string) {
- let data = old_parse(string);
- blurMedia(data);
- return data;
- };
- exportFunction(new_parse, unsafeWindow.JSON, { defineAs: "parse" });
- })();