Guest User

Untitled

a guest
Jan 14th, 2021
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. // ==UserScript==
  2. // @name HN
  3. // @description Hacker News User Script
  4. // @match *://news.ycombinator.com/*
  5. // ==/UserScript==
  6.  
  7. const domainblacklist = [
  8. "bbc.com",
  9. "twitter.com",
  10. "economist.com",
  11. "npr.org",
  12. "eff.org",
  13. "businessinsider.com",
  14. "theguardian.com",
  15. "engadget.com",
  16. "reuters.com",
  17. "buzzfeednews.com",
  18. "wsj.com",
  19. "newyorker.com",
  20. "wikipedia.org",
  21. "thehill.com",
  22. "arstechnica.com",
  23. "washingtonpost.com",
  24. "cnn.com",
  25. "nytimes.com",
  26. "axios.com",
  27. "bbc.co.uk",
  28. "mercurynews.com",
  29. "nih.gov"
  30. ]
  31. function matchesBlacklist(href) {
  32. for (let bl of domainblacklist) {
  33. if (href.indexOf(bl) >= 0) return true;
  34. }
  35. return false;
  36. }
  37. function removePost(anchor) {
  38. const tr = anchor?.parentNode?.parentNode?.parentNode;
  39. console.log("removing:", anchor, tr)
  40. const nsibling = tr?.nextElementSibling
  41. const psibling = tr?.previousElementSibling
  42. if (tr) {tr.parentNode.removeChild(tr)}
  43. if (nsibling) {nsibling.parentNode.removeChild(nsibling)}
  44. if (psibling) {psibling.parentNode.removeChild(psibling)}
  45. }
  46. for (let itm of document.querySelectorAll(".itemlist tr .sitebit a") || []) {
  47. if (matchesBlacklist(itm.getAttribute("href") || "")) removePost(itm);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment