Skip to content

Instantly share code, notes, and snippets.

@bartread
Created September 11, 2024 14:55
Show Gist options
  • Save bartread/11cc72620ed0f7c0b04287de0547c7a6 to your computer and use it in GitHub Desktop.
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)
// ==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