Twitter Discreet Blocking

Blocks twitter users only locally

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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});
})()