Greasy Fork is available in English.

Better Reddit Spoiler

Improved spoiler formatting for Reddit

  1. // ==UserScript==
  2. // @name Better Reddit Spoiler
  3. // @version 0.3
  4. // @description Improved spoiler formatting for Reddit
  5. // @author Drazen Bjelovuk
  6. // @match *://www.reddit.com/*/comments/*
  7. // @grant none
  8. // @run-at document-end
  9. // @namespace https://greasyfork.org/users/11679
  10. // @contributionURL https://goo.gl/dYIygm
  11. // ==/UserScript==
  12.  
  13. var anchors = document.getElementsByTagName('a');
  14. for (var i = 0; i < anchors.length; i++) {
  15. var anchor = anchors[i];
  16. if (anchor.href === 'https://www.reddit.com/s' || anchor.href === 'https://www.reddit.com/spoiler') {
  17. var spoiler = document.createElement('span');
  18. spoiler.innerHTML = anchor.title || anchor.textContent;
  19. spoiler.style.backgroundColor = '#222222';
  20. spoiler.onmouseover = function() { this.style.backgroundColor = 'white'; };
  21. spoiler.onmouseout = function() { this.style.backgroundColor = '#222222'; };
  22. anchor.parentNode.replaceChild(spoiler, anchor);
  23. }
  24. }