-
-
Save kennethrapp/5b5e413220afb93c9c93 to your computer and use it in GitHub Desktop.
HN cure undead
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 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