Skip to content

Instantly share code, notes, and snippets.

@whatisjasongoldstein
Created August 18, 2012 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatisjasongoldstein/3388606 to your computer and use it in GitHub Desktop.
Save whatisjasongoldstein/3388606 to your computer and use it in GitHub Desktop.
Depoliticize Twitter
var ignored = ['obama', 'romney', 'paul ryan', 'mittromney', 'biden', 'joebiden', 'barrackobama', 'politico', 'liberal', 'conservative', 'fox news'];
var removePolitics = function(){
console.log('Removing political tweets.')
var tweets = $('.tweet');
var tweet, tweet_content;
for (var i = 0; i < tweets.length; i++) {
tweet = $(tweets[i]);
tweet_content = tweet.html().toLowerCase();
for (var f = 0; f < ignored.length; f++) {
if (tweet_content.search(ignored[f]) > -1){
console.log('Removing a political tweet from @'+ $(tweet).attr('data-screen-name'));
tweet.remove();
break;
}
}
}
};
var init = function(){
if (typeof $ === "undefined") {
var url = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
var script_tag = document.createElement('script');
script_tag.setAttribute("src", url);
script_tag.onload = removePolitics; // Run callback once jQuery has loaded
document.getElementsByTagName("head")[0].appendChild(script_tag);
} else {
removePolitics();
}
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment