Created
August 18, 2012 17:33
-
-
Save whatisjasongoldstein/3388606 to your computer and use it in GitHub Desktop.
Depoliticize Twitter
This file contains hidden or 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
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