Guest User

Untitled

a guest
Jan 22nd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. /*To use this function, open up Twitter, open a console in dev mode,
  2. paste the function in below, and then run,
  3. var intervalId = window.setInterval(removeGarbage, 1000);
  4. if you wish to stop this removing all the extra tweets every second,
  5. window.clearInterval(intervalId);
  6. */
  7. function removeGarbage(){
  8. var tweets=document.querySelectorAll('.js-stream-item.stream-item.stream-item');
  9. var tweetsToRemove=Array();
  10. for (var i=0; i<tweets.length; i++){
  11. dataJson = JSON.parse(tweets[i].getAttribute('data-suggestion-json'));
  12. if (dataJson.suggestion_details.suggestion_type == null){
  13. //this little if condition is to stop threaded tweets being removed
  14. if(dataJson.tweet_ids!='' && dataJson.scribe_component=='tweet'){
  15. tweetsToRemove.push(tweets[i]); //this removes all ads
  16. }
  17. }
  18. else if (dataJson.suggestion_details.suggestion_type == "RecycledTweet"){
  19. tweetsToRemove.push(tweets[i]); // Removes the in case you missed it section
  20. }
  21. else if(dataJson.suggestion_details.suggestion_type == "ActivityTweet"){
  22. tweetsToRemove.push(tweets[i]); // this removes all tweets liked by a person
  23. }
  24. else if(dataJson.suggestion_details.suggestion_type == "RecycledTweetInline"){
  25. tweetsToRemove.push(tweets[i]); //Twitter does this weird thing of bringing back retweets from the past. Nuke em!
  26. }
  27. else if(dataJson.suggestion_details.suggestion_type == "RankedOrganicTweet"){
  28. //All the stuff below is super aggressive. Removes quotes and retweets. Remove either or both the conditions
  29. //if its too aggressive for your liking
  30. if(tweets[i].querySelector('span.Icon.Icon--small.Icon--retweeted')!==null){
  31. tweetsToRemove.push(tweets[i]); // This removes any retweets
  32. }
  33. if(tweets[i].querySelector('div.QuoteTweet')!==null){
  34. tweetsToRemove.push(tweets[i]); // This removes any quoted tweets
  35. }
  36. }
  37.  
  38. }
  39. for (var i=0; i<tweetsToRemove.length; i++){
  40. tweetsToRemove[i].remove(); //this is probably a bad idea. I don't know. It works :D
  41. }
  42. }
Add Comment
Please, Sign In to add comment