Skip to content

Instantly share code, notes, and snippets.

@kennethrapp kennethrapp/HN_Cure_Undead.user.js Secret
Last active Aug 29, 2015

Embed
What would you like to do?
HN cure undead
// ==UserScript==
// @name HN Cure Undead
// @namespace kennethrapp1@gmail.com
// @include *news.ycombinator.com*
// @description unfade HN comments
// @version 2
// @grant none
// ==/UserScript==
var HackerNewsCureUndead = {
AffectDOMPath: function (expression, callback) {
var result = document.evaluate(expression, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
if (result.snapshotLength) {
for (i = 0; i <= result.snapshotLength - 1; i++) {
callback.call(this, result.snapshotItem(i));
}
}
},
Run: function () {
var regex;
// unfade comments
this.AffectDOMPath('//span[@class=\'comment\']', function (node) {
regex = new RegExp('<span class="c([0-9A-F]{2})">', 'gim');
node.innerHTML = node.innerHTML.replace(regex, function (i) {
return '<span clas="c00">';
});
});
// unfade text posts
this.AffectDOMPath('//td', function (node) {
node.setAttribute('style', 'color:#000000');
});
}
}.Run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.