Reddit Sub Filter

Filter subs from r/all.

  1. // ==UserScript==
  2. // @name Reddit Sub Filter
  3. // @namespace http://*.reddit.*/r/all*
  4. // @version 1.023
  5. // @grant none
  6. // @description:en Filter subs from r/all.
  7. // @description Filter subs from r/all.
  8. // @include https://*.reddit.*/r/all*
  9. // @include http://*.reddit.*/r/all*
  10. // ==/UserScript==
  11.  
  12. // This list based on: https://gist.github.com/kimagure/4490644
  13. // Edit to your Reddit preferences.
  14. horriblesubreddits = [
  15. 'trees',
  16. 'wtf',
  17. // 'politics',
  18. // 'gonewild',
  19. // 'todayilearned',
  20. // '4chan',
  21. // 'pokemon',
  22. // 'reactiongifs',
  23. // 'fffffffuuuuuuuuuuuu',
  24. // 'atheism',
  25. // 'adviceanimals',
  26. 'firstworldanarchists',
  27. 'ImGoingToHellForThis',
  28. 'TwoXChromosomes',
  29. // 'mildlyinteresting',
  30. // 'nsfw',
  31. 'gentlemanboners',
  32. // 'RealGirls',
  33. 'creepy',
  34. 'The_Donald',
  35. 'cringepics',
  36. 'niceguys',
  37. 'natureismetal',
  38. 'justneckbearthings',
  39. 'lifeprotips',
  40. ];
  41.  
  42. var shitty_subs = document.getElementsByClassName("subreddit");
  43.  
  44. for (var i = shitty_subs.length - 1; i > -1; i--) {
  45. var url = shitty_subs[i].href.toLowerCase();
  46.  
  47. for (var j = 0; j < horriblesubreddits.length; j++) {
  48. if (url.indexOf(horriblesubreddits[j].toLowerCase()) != -1) {
  49. //shitty_subs[i].parentNode.parentNode.parentNode.remove(); // Uncomment this line and comment or remove the next 4 lines to hide the post completely
  50.  
  51. /*
  52. shitty_subs[i].parentNode.parentNode.children[0].children[0].innerHTML = "{CENSORED}";
  53. shitty_subs[i].parentNode.parentNode.children[0].children[0].style["font-weight"] = "bold";
  54. shitty_subs[i].parentNode.parentNode.children[0].children[0].href = "";
  55. shitty_subs[i].parentNode.parentNode.parentNode.children[3].href = "";
  56. */
  57. // console.log(shitty_subs[i].parentNode.parentNode.children[0].children[0]);
  58. var a = document.createElement('a');
  59. a.innerHTML = "{CENSORED}";
  60. a.style["font-weight"] = "bold";
  61. a.style["color"] = "#551a8b";
  62. a.href = "";
  63. shitty_subs[i].parentNode.parentNode.children[0].insertBefore(a, shitty_subs[i].parentNode.parentNode.children[0].children[1]);
  64. shitty_subs[i].parentNode.parentNode.children[0].children[0].remove();
  65. /*
  66. // Code to fix Reddit restoring the blocked link
  67. var link = shitty_subs[i].parentNode.parentNode.children[0].children[0];
  68. var clone = link.cloneNode(true);
  69. link.parentNode.replaceChild(clone, link);
  70. */
  71. }
  72. }
  73. }