Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*To use this function, open up Twitter, open a console in dev mode,
- paste the function in below, and then run,
- var intervalId = window.setInterval(removeGarbage, 1000);
- if you wish to stop this removing all the extra tweets every second,
- window.clearInterval(intervalId);
- */
- function removeGarbage(){
- var tweets=document.querySelectorAll('.js-stream-item.stream-item.stream-item');
- var tweetsToRemove=Array();
- for (var i=0; i<tweets.length; i++){
- dataJson = JSON.parse(tweets[i].getAttribute('data-suggestion-json'));
- if (dataJson.suggestion_details.suggestion_type == null){
- //this little if condition is to stop threaded tweets being removed
- if(dataJson.tweet_ids!='' && dataJson.scribe_component=='tweet'){
- tweetsToRemove.push(tweets[i]); //this removes all ads
- }
- }
- else if (dataJson.suggestion_details.suggestion_type == "RecycledTweet"){
- tweetsToRemove.push(tweets[i]); // Removes the in case you missed it section
- }
- else if(dataJson.suggestion_details.suggestion_type == "ActivityTweet"){
- tweetsToRemove.push(tweets[i]); // this removes all tweets liked by a person
- }
- else if(dataJson.suggestion_details.suggestion_type == "RecycledTweetInline"){
- tweetsToRemove.push(tweets[i]); //Twitter does this weird thing of bringing back retweets from the past. Nuke em!
- }
- else if(dataJson.suggestion_details.suggestion_type == "RankedOrganicTweet"){
- //All the stuff below is super aggressive. Removes quotes and retweets. Remove either or both the conditions
- //if its too aggressive for your liking
- if(tweets[i].querySelector('span.Icon.Icon--small.Icon--retweeted')!==null){
- tweetsToRemove.push(tweets[i]); // This removes any retweets
- }
- if(tweets[i].querySelector('div.QuoteTweet')!==null){
- tweetsToRemove.push(tweets[i]); // This removes any quoted tweets
- }
- }
- }
- for (var i=0; i<tweetsToRemove.length; i++){
- tweetsToRemove[i].remove(); //this is probably a bad idea. I don't know. It works :D
- }
- }
Add Comment
Please, Sign In to add comment