Skip to content

Instantly share code, notes, and snippets.

@twome twome/README.md
Last active Apr 2, 2019

Embed
What would you like to do?
Browser patch: [Twitter] Boring Tweet Remover

Hide Twitter users unless they're getting ratio'd. This allows you to effectively hate-follow odious individuals without exhausting your irony supply.

Reveals:

  • "Classic" ratios
  • Coward's Ratios
  • Public Service Announcements (huge RT:fav ratio)

J4cK-r3l473d Gr33tZ

  • Jacky Vening, Idea Inventor
  • Jackie's Podcast
  • Jack Dorsey is a fascist enemy of the people and dresses like if Neo was originally portrayed by Steven Seagal
/*.stream-item*/.NotJuicyEnough {
background-color: hsl(352, 100%, 85%);
padding: 0.3em;
font-style: italic;
color: hsla(0,0%,0%,0.4);
display: block;
text-align: center;
}
let getStatAsInt = (el, statStr) => {
let statKind = el.querySelector(`.ProfileTweet-action--${statStr}`)
if (!statKind) return Error(`No 'action' element for ${statStr}`)
// Here we'll look for a bunch of different methods that Twitter uses to show the number of times a given action happened.
let dataAttr = statKind.querySelector(`[data-tweet-stat-count]`)
if (dataAttr) return parseInt(dataAttr.dataset.tweetStatCount, 10)
let isZero = statKind.querySelector('.ProfileTweet-actionCount--isZero')
if (isZero) return 0
let forPresentation = statKind.querySelector('.ProfileTweet-actionCountForPresentation')
if (forPresentation) return parseInt(forPresentation.innerText, 10)
return Error(`No count for action ${statStr} found.`)
}
let replaceTweetWithPlaceholder = tweetEl => {
// "Stream items" are tweet threads/reply chains
let streamItem = tweetEl.closest('.stream-item')
let linkUrl = tweetEl.dataset.permalinkPath
// This is the placeholder 'blocked' element we'll create to show that a tweet's been hidden
let blockEl = document.createElement('a')
blockEl.href = linkUrl
blockEl.innerText = '[tweet insufficiently juicy to bother displaying]'
blockEl.classList.add('NotJuicyEnough') // See the CSS for what these styles look like
streamItem.innerHTML = ''
streamItem.appendChild(blockEl)
}
let filterOutBoringTweets = ({
blockedUsersList,
minRatioOfRepliesPerFav = 0.5, // Minimum ratio for getting ratio'd
maxRatioOfRetweetsPerFav = 0.1, // Maximum ratio for a Coward's Ratio
minPsaRatioOfRetweetsPerFav = 0.8, // Minimum retweet ratio for a Public Service Announcement
}={}) => {
let allTweets = document.querySelectorAll('.tweet')
allTweets.forEach(tweetEl => {
let owner = tweetEl.dataset.screenName
let ownerIsBlocked = blockedUsersList.includes(owner)
let id = tweetEl.dataset.tweetId
let replies = getStatAsInt(tweetEl, 'reply')
let retweets = getStatAsInt(tweetEl, 'retweet')
let favs = getStatAsInt(tweetEl, 'favorite')
let counts = [replies, retweets, favs]
counts.forEach(count => {
if (count instanceof Error){
return false // Give up; we can't find any useful info from the DOM
}
})
let classicRatio = (replies / favs) >= minRatioOfRepliesPerFav
let cowardsRatio = (retweets / favs) <= maxRatioOfRetweetsPerFav
let psa = (retweets / favs) >= minPsaRatioOfRetweetsPerFav
if (ownerIsBlocked){
if (classicRatio || cowardsRatio || psa){
// Tweet displays as normal
} else {
replaceTweetWithPlaceholder(tweetEl)
}
}
})
}
// TODO: Search for replies to tweets with >= 1x favs vs the OP
setInterval(()=>{
filterOutBoringTweets({
blockedUsersList: [
'JerkVening' // Obviously
]
})
}, 500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.