TheDailyWTF (Worse Than Failure) Comments

Script to show authors' HTML comments on thedailywtf.com

  1. // ==UserScript==
  2. // @name TheDailyWTF (Worse Than Failure) Comments
  3. // @namespace namespace
  4. // @description:en Script to show authors' HTML comments on thedailywtf.com
  5. // @include http://thedailywtf.com/*
  6. // @version 1
  7. // @grant none
  8. // @description Script to show authors' HTML comments on thedailywtf.com
  9. // ==/UserScript==
  10.  
  11. var author = document
  12. .getElementsByClassName("author")[0]
  13. .getElementsByTagName("h4")[0]
  14. .innerHTML;
  15.  
  16. var title = "<strong>" +author + "</strong>: ";
  17.  
  18. var article = document.getElementsByClassName("article-body")[0];
  19. var newArticleHTML = article.innerHTML;
  20.  
  21. while(newArticleHTML.search("<!--") > -1) {
  22. newArticleHTML = newArticleHTML
  23. .replace("<!--", "<em style='background-color: lightgrey; font-size: 0.7em;'>(" + title)
  24. .replace("-->", ")</em>");
  25. }
  26.  
  27. article.innerHTML = newArticleHTML;