removeFacebookSuggestedPosts

Remove facebook suggested posts and games

目前为 2016-08-11 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name removeFacebookSuggestedPosts
  3. // @namespace DT
  4. // @description Remove facebook suggested posts and games
  5. // @include https://www.facebook.com/
  6. // @version 2
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. var DT = {};
  11.  
  12. DT._ticking = false;
  13. DT._unwanted = ['Suggested Post', 'Suggested Game'];
  14.  
  15. DT.main = function(){
  16. var spans = document.getElementsByTagName("SPAN");
  17. var totalSpans = spans.length;
  18. for(var i = 0; i < totalSpans; i++){
  19. var item = spans.item(i);
  20. if(item && DT._unwanted.indexOf(item.textContent) > -1){
  21. var parent = item.parentNode.parentNode.parentNode.parentNode.parentNode;
  22. if(parent){
  23. parent.parentNode.removeChild(parent);
  24. console.log('Removed suggested post');
  25. }
  26. }
  27. }
  28. };
  29.  
  30. DT._tick = function(){
  31. if(!DT._ticking){
  32. window.setTimeout(function(){
  33. DT.main();
  34. DT._ticking = false;
  35. }, 3000);
  36. }
  37. DT._ticking = true;
  38. };
  39.  
  40. document.addEventListener("DOMContentLoaded", DT._tick);
  41. window.addEventListener('scroll', DT._tick);