Skip to content

Instantly share code, notes, and snippets.

@Hugovdberg
Last active August 21, 2018 09:32
Show Gist options
  • Select an option

  • Save Hugovdberg/774c02008f5f94b53302e6d4688b52a9 to your computer and use it in GitHub Desktop.

Select an option

Save Hugovdberg/774c02008f5f94b53302e6d4688b52a9 to your computer and use it in GitHub Desktop.
Remify & Cornify The Daily WTF
// ==UserScript==
// @name Remify & Cornify The Daily WTF
// @namespace https://github.com/Hugovdberg
// @version 0.2.1
// @description Replace comments with dark green text and highlight the cornify spans.
// @author Hugo van den Berg
// @match thedailywtf.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function remify(idx, article) {
article.innerHTML = article.innerHTML.replace(/<!--[^>]+?-->/g, function(comment) {
return comment
.replace(/<!\-\-/g, '&nbsp;<span style="color: green; font-weight: bold;">')
.replace(/\-\->/g, '</span>&nbsp;')
.replace(/(https?:\/\/[^ ]+)/g, '<a href="$1">$1</a>');
});
}
$('.article-body').each(remify);
$('.ArticleBody').each(remify);
$('#ArticleFull').each(remify);
$('[onclick^=cornify]').each(function(idx, corny){
console.log(corny);
corny.style.color = "#ff7f95";
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment