Twitter Discreet Blocking

Blocks twitter users only locally

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Twitter Discreet Blocking
// @namespace   Violentmonkey Scripts
// @match       https://twitter.com/home
// @grant       none
// @version     1.1
// @author      CarlosMarques
// @description Blocks twitter users only locally
// @license      MIT
// ==/UserScript==
 
//TODO: User interface to add blocked users
 
(function(){
	let blockedAccounts = ["elonmusk"]
	let mObserver = new MutationObserver(function(mutations){
		for(tweet of document.querySelectorAll('[data-testid="cellInnerDiv"]')){
			let tweetAuthor = tweet.querySelector('[data-testid="User-Name"]')?.querySelector('[role="link"]').href.split("/").slice(-1)[0]
			let tweetReposter = tweet.querySelector('[data-testid="socialContext"]')?.parentElement.href.split("/").slice(-1)[0]
			if(blockedAccounts.includes(tweetAuthor) || blockedAccounts.includes(tweetReposter)){
				tweet.innerHTML = ""
				tweet.style = ""
			}
		}
	})
	mObserver.observe(document.body, {subtree: true, childList: true, characterData: true});
})()