Block ads on bitcointalk.

bitcointalk.org is filled with scammy ads. free yourself from the noise.

  1. // ==UserScript==
  2. // @name Block ads on bitcointalk.
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3.1
  5. // @description bitcointalk.org is filled with scammy ads. free yourself from the noise.
  6. // @author itsnotlupus
  7. // @match https://bitcointalk.org/*
  8. // ==/UserScript==
  9.  
  10. /*jshint esversion:6 */
  11.  
  12. // On this forum, users are allowed to advertise for whatever scam they want, in their signatures, profile pic and profile byline.
  13. // This is in addition to any site-level ads.
  14. // This script aims to remove all of it.
  15.  
  16. const junk = [
  17. // ad and shitty signatures
  18. "table>tbody>tr>td>table>tbody>tr>td>div:not([id]):not(.post):not(.subject):not(.personalmessage):not(.smalltext)[class]",
  19. // ad disclaimer
  20. "form>table>tbody>tr>td>span",
  21. // extraneous <hr> tags
  22. "td.smalltext hr"
  23. ];
  24.  
  25. // remove the junk
  26. junk.forEach(line => document.querySelectorAll(line).forEach(t => t.remove()));
  27.  
  28. // scrub poster info too, since it's filled with ads too nowadays.
  29. document.querySelectorAll(".poster_info>.smalltext>div").forEach(poster => {
  30. let m, n = poster.nextSibling;
  31. // crawl through nodes found under a poster profile pic
  32. do {
  33. m = n.nextSibling;
  34. // custom text under a profile pic? that's almost always an ad.
  35. if (n instanceof Text) n.remove();
  36. // custom link? yes, probably an ad.
  37. if (n.href && !n.href.startsWith("https://bitcointalk.org/")) n.remove();
  38. } while (n = m);
  39. // and of course, remove the profile pic, because it's almost certainly an ad.
  40. poster.remove();
  41. });
  42.  
  43. // avoid a JS error caused by their broken anti-adblock code.
  44. window.detectabp = () => false;
  45.  
  46. // why are you even using this terrible forum? nostalgia? masochism?