Created
August 4, 2016 14:40
-
-
Save kirsn/316cfddbf5dc46dd126c423f112cfc8d to your computer and use it in GitHub Desktop.
Remove tweets that contains terms or topics you are not interested in
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 - Filter | |
// @namespace tf | |
// @author http://twitter.com/kirsn | |
// @description Remove tweets which are of no interest | |
// @include https://twitter.com/ | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
/* All filter terms in CAPS */ | |
var filterTerms = [ | |
'TRUMP', | |
'RAKSHAK' | |
]; | |
/*Remove tweets that match the filter terms*/ | |
function twitterFilter() { | |
var ts = document.getElementsByClassName('tweet'); | |
for (var i = 0; i < ts.length; i++) { | |
var tweetText = ts[i].textContent.toUpperCase(); | |
for (var j = 0; j < filterTerms.length; j++) { | |
if (tweetText.indexOf(filterTerms[j].toUpperCase()) > 0) { | |
ts[i].remove(); | |
break; | |
} | |
} | |
} | |
} | |
/*Perform this cleanup every 5 seconds*/ | |
window.setInterval(twitterFilter, 5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple Filter for your Twitter timeline
Not interested in reading about some topics on your Twitter timeline? You can just remove them, automatically, with this technique.
I use Twitter to follow some topics - mostly technology, art, some politics and a few other random things. Some topics I choose not to follow on twitter, and instead choose to read about in a newspaper (an editorial, or article with a byline)
So, created the following Greasemonkey script. This should have been a two minute endeavour, but minimal competence in Javascript, it took me a while to figure out things.
How you can use this, from within your desktop browser: