Skip to content

Instantly share code, notes, and snippets.

@chunrapeepat
Created April 5, 2023 08:19
Show Gist options
  • Save chunrapeepat/cf4e2f5a3e706d3ac7da434f6237b5cb to your computer and use it in GitHub Desktop.
Save chunrapeepat/cf4e2f5a3e706d3ac7da434f6237b5cb to your computer and use it in GitHub Desktop.
Make Twitter suck less
// ==UserScript==
// @name Hide Twitter Replies (Home)
// @version 1
// @description Hide all reply elements in a Twitter home page.
// @author Chun Rapeepat
// @match https://twitter.com/home
// @grant none
// ==/UserScript==
(function() {
'use strict';
// hide replies
function hideReplies() {
const tweetList = document.querySelectorAll("article[data-testid='tweet']");
Array.from(tweetList).forEach(tweet => {
const replyContent = tweet.innerText.includes('Replying to');
if (replyContent) {
tweet.style.display = 'none';
}
});
}
const observer = new MutationObserver(hideReplies);
observer.observe(document.body, { childList: true, subtree: true });
hideReplies();
// remove Twitter logo
function hideLogo() {
document.querySelector("h1[role='heading'").style.display = 'none';
}
const observerLogo = new MutationObserver(hideLogo);
observerLogo.observe(document.body, { childList: true, subtree: true });
hideLogo();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment