Reddit: Low Upvote Filter

Hide font page posts with fewer than 10 upvotes (edit minimum in the code)

  1. // ==UserScript==
  2. // @name Reddit: Low Upvote Filter
  3. // @description Hide font page posts with fewer than 10 upvotes (edit minimum in the code)
  4. // @match https://www.reddit.com/*
  5. // @version 0.1
  6. // @author mica
  7. // @namespace greasyfork.org/users/12559
  8. // @license MIT
  9. // ==/UserScript==
  10.  
  11. const minUpvote = 10;
  12. const observer = new MutationObserver(() => {
  13. if (location.pathname == '/') {
  14. document.querySelectorAll('button[aria-label="upvote"]:not(.checked)').forEach(element => {
  15. if (element.nextSibling.innerText < minUpvote) {
  16. element.closest('div.scrollerItem').remove();
  17. } else {
  18. element.classList.add('checked');
  19. }
  20. });
  21. }
  22. });
  23. observer.observe(document.body, {
  24. childList: true,
  25. subtree: true
  26. });