Last active
October 8, 2015 18:48
-
-
Save willh/3373992 to your computer and use it in GitHub Desktop.
Clean up Twitter by hiding tweets by matching on content and removing trends and 'promoted' tweets
This file contains 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 Twitter Cleanup | |
// @description Remove crap from your Twitter feed without unfollowing people | |
// @author @willhamill | |
// @include https://twitter.com/* | |
// @include https://www.twitter.com/* | |
// @include http://twitter.com/* | |
// @include http://www.twitter.com/* | |
// ==/UserScript== | |
(function(){ | |
function hideTweetMatchingText(matchString) { | |
var elems = document.getElementsByTagName('p'), i; | |
for (i in elems) { | |
if((" " + elems[i].className + " ").indexOf(" " + "js-tweet-text" + " ") > -1) { | |
var boringTweet = elems[i] | |
if (boringTweet.innerHTML.indexOf(matchString) != -1) { | |
// hide great-grandparent div to disappear the entire tweet | |
boringTweet.parentNode.parentNode.parentNode.style.display = "none" | |
} | |
} | |
} | |
} | |
hideTweetMatchingText("http://4sq.com") | |
hideTweetMatchingText("http://pinterest.com/pin") | |
hideTweetMatchingText("http://instagr.am") | |
})(); | |
(setTimeout(function(){ | |
var elems = document.getElementsByTagName('div'), i; | |
for (i in elems) { | |
if((elems[i].className).indexOf("trends-inner") > -1) { | |
var trendsHeader = elems[i] | |
trendsHeader.style.display = "none" | |
} | |
} | |
var elems = document.getElementsByTagName('a'), i; | |
for (i in elems) { | |
if((elems[i].className).indexOf("js-promoted-badge") > -1) { | |
var promotedLink = elems[i] | |
promotedLink.parentNode.style.display = "none" | |
} | |
} | |
}, 2000))(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First function removes any tweets containing a given content, e.g. links to FourSquare.
Second function removes the Trends left-side div.
Third function removes any 'promoted' tweet.