Skip to content

Instantly share code, notes, and snippets.

@kennethrapp
Last active November 30, 2015 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kennethrapp/7a21c0187fedd6f47e7c to your computer and use it in GitHub Desktop.
Save kennethrapp/7a21c0187fedd6f47e7c to your computer and use it in GitHub Desktop.
Hacker News greentext greasemonkey plugin
// ==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('>&gt;(.+?)<','gim');
node.innerHTML = node.innerHTML.replace(regex, '><font color="#195708">&gt;$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