Created
September 11, 2024 14:55
-
-
Save bartread/11cc72620ed0f7c0b04287de0547c7a6 to your computer and use it in GitHub Desktop.
ViolentMonkey/TamperMonkey/Greasemonkey script to hide tweets from Elon Musk or any other unblockable user on X (formerly known as twitter)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Hide Elon Musk (or other unblockable user) tweets | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0.1 | |
// @description Hide tweets from @elonmusk on X.com (formerly Twitter); change username for any other user | |
// @author Bart Read | |
// @match https://*.x.com/* | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
'use strict'; | |
function hideUnblockableUserTweets() { | |
// Change username in here to hide tweets from that user | |
const userLinks = document.querySelectorAll('a[href="/elonmusk"]'); | |
userLinks.forEach(link => { | |
let parentDiv = link; | |
for (let i = 0; i < 11; i++) { | |
if (parentDiv) { | |
parentDiv = parentDiv.parentElement; | |
} | |
} | |
if (parentDiv) { | |
parentDiv.style.display = 'none'; | |
} | |
}); | |
} | |
hideUnblockableUserTweets(); | |
const observer = new MutationObserver(() => { | |
hideUnblockableUserTweets(); | |
}); | |
observer.observe(document.body, { | |
childList: true, | |
subtree: true, | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment