Last active
October 2, 2018 20:53
-
-
Save rummik/10572326 to your computer and use it in GitHub Desktop.
Backing up a script I wrote forever ago...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name WTF? Comments! | |
// @description Show hidden comments in TDWTF articles (especially Remy Porter's) | |
// @author rummik | |
// @include https://thedailywtf.com/* | |
// @version 0.009.35 | |
// ==/UserScript== | |
!function() { | |
'use strict'; | |
let $ = (q,e) => [].slice.apply((e||document).querySelectorAll(q)); | |
$('.article-body, article .container').forEach(article => { | |
$('span[onclick]', article).forEach(span => span.style.color = '#c44'); | |
article.innerHTML = article.innerHTML.replace(/<!--[^>]+?-->/g, comment => { | |
comment = comment | |
.replace(/^<!--|-->$/g, '') | |
.replace(/(https?:\/\/[^ ]+)/g, '<a href="$1">$1</a>'); | |
return `<em style="color: #080"> <!--${comment}--> </em>`; | |
}); | |
}); | |
}(); | |
// ==ChangeLog== | |
// 0.009.34: Minor tweaks. | |
// 0.009.33: Update for new site, sprinkle in some ES6. | |
// 0.009.32: Fix @include to work on all subpages on The Daily WTF. | |
// 0.009.31: Make cornify coloring happen again. (Thanks Don!) | |
// 0.009.30: Fix bug with comment matching, shorten $. | |
// 0.009.29: Misc. | |
// 0.009.28: Source cleanup. | |
// 0.009.27: Removed jQuery. | |
// 0.009.26: Fixed URLs breaking comments. | |
// 0.009.25: Updated description to be more accurate. | |
// 0.009.24: Added support for showing spans with OnClick events. (Cornify, anyone?) | |
// 0.009.23: Added changelog. | |
// 0.009.22: Changed version numbering. | |
// 0.00921: Added support for links in comments. | |
// 0.00918: Fixed bug that caused all articles on a page to show the same text. | |
// 0.00913: Changed require for jQuery to the latest version... | |
// 0.00912: Added require for jQuery. | |
// 0.0091: Initial release. | |
// ==/ChangeLog== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment