-
-
Save kennethrapp/7a21c0187fedd6f47e7c to your computer and use it in GitHub Desktop.
Hacker News greentext greasemonkey plugin
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 Hacker News Greentext | |
// @namespace kennethrapp1@gmail.com | |
// @include *news.ycombinator.com* | |
// @description greentext for Hacker News Wat?! | |
// @version 6 | |
// @grant none | |
// ==/UserScript== | |
var HackerNewsGreentext = { | |
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; | |
this.AffectDOMPath("//span[@class='comment']", function(node){ | |
regex = new RegExp('>>(.+?)<','gim'); | |
node.innerHTML = node.innerHTML.replace(regex, '><font color="#195708">>$1</font><'); | |
}); | |
//.dead | |
this.AffectDOMPath("//td | //*[@class='dead']", 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