3 reviews
Review written by darlyn - see all my reviews (1)
The only issue I have with this is that the OP's comments are too prominent. I modified line 35 so that instead of a blue background behind the user ID, there is a small gray arrow to the left of it (screenshot here). The arrow comes directly from reddit's servers, thus it will never go offline.
Line 35:
GM_addStyle("a.author[href$='/"+authorName+"/'] { background:url('http://www.reddit.com/static/droparrowgray.gif') no-repeat; padding-left:20px; }");
Great script, I had to make a few minor fixes to get it to work though:
Change line 25 to var authorName = $xpath("//div[@id='siteTable']//a[@class='author']/text()")[0].nodeValue;
Comment out line 27.
Change line 30 to var isSelf = (link_domain.indexOf("self.") != -1);s.
Change line 44 to var topLevelByOP = $xpath("//div[@class='content']/div[starts-with(@id, 'siteTable_')]/div[starts-with(@class, ' thing id')][div[@class='entry']/div[@class='noncollapsed']/p[@class='tagline']/a[@class='author'][text()='"+authorName+"']]");
After that, it worked perfectly.
Edit: apparently this isn't working for some people, so here's the complete modified script that I'm using:
// ==UserScript==
// @name Highlight OP's comments on Reddit self-posts
// @namespace tag:brainonfire.net,2008-12-10:reddit-selfpost-highlight-OP
// @description In Reddit self-posts, the submitter often puts the bulk of their submission in a comment instead of the headline, and the comment may get buried. This will highlight their comments and bring their oldest top-level comment to the top of the page.
// @include http://www.reddit.com/comments/*
// @include http://www.reddit.com/r/*/comments/*
// @version 0.3
// @changelog Since 0.2: Bring oldest top-level comment by OP to the top.
// ==/UserScript==
/* From http://wiki.greasespot.net/Code_snippets */
function $xpath(p, context)
{
if(!context)
context = document;
var i;
var arr = [];
var xpr = document.evaluate(p, context, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for(i = 0; item = xpr.snapshotItem(i); i++)
arr.push(item);
return arr;
}
var authorName = $xpath("//div[@id='siteTable']//a[@class='author']/text()")[0].nodeValue;
//var actual_subreddit = unsafeWindow.post_site;
var link_domain = $xpath("//div[@id='siteTable']//span[@class='domain']/a/text()")[0].nodeValue;
var isSelf = (link_domain.indexOf("self.") != -1);
if(!isSelf)
return;
GM_addStyle("a.author[href$='/"+authorName+"/'] { background-color: #af8; }");
//also bring OP's oldest top-level comment to top, if applicable
var isPermalink = !!$xpath("//div[@class='permamessage']").length;
if(isPermalink)
return;
var topLevelByOP = $xpath("//div[@class='content']/div[starts-with(@id, 'siteTable_')]/div[starts-with(@class, ' thing id')][div[@class='entry']/div[@class='noncollapsed']/p[@class='tagline']/a[@class='author'][text()='"+authorName+"']]");
var re_ID = /.*_(.+)/;
function selectOlderComment(a, b)
{
return re_ID.exec(a.id)[1] < re_ID.exec(b.id)[1] ? a : b;
}
if(topLevelByOP.length === 0)
return;
topLevelByOP = topLevelByOP.reduce(selectOlderComment);
var siteTable = topLevelByOP.parentNode;
var clearer = topLevelByOP.nextSibling;
siteTable.removeChild(topLevelByOP);
siteTable.removeChild(clearer);
siteTable.insertBefore(clearer, siteTable.firstChild);
siteTable.insertBefore(topLevelByOP, siteTable.firstChild);
reddits changed a bit and noticed this stopped working:
[starts-with(@id, 'author_')]
