I dont recall how I did it, but mine works.
Code:
// ==UserScript==
// @name 2p2 link to first unread post
// @author John "jalexand42" Alexander
// @namespace http://www.jvelliott.com/2p2scripts/
// @description links to first unread post & removes default vbb image - originally created by http://henrik.nyh.se
// @include http://forums.twoplustwo.com/forumdisplay*
// ==/UserScript==
var rx = new RegExp("^http://forumserver.twoplustwo.com/[0-9]+/[a-z0-9-]+/[?a-z0-9=]*$");
var ry = new RegExp("^http://forumserver.twoplustwo.com/usercp.php");
var rz = new RegExp("^http://forumserver.twoplustwo.com/subscription.php");
if (!rx.test(document.location) && !ry.test(document.location) && !rz.test(document.location))
{
return;
}
function xp(query, root) { return document.evaluate(query, root || document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); }
function xps(query, root) { return document.evaluate(query, root || document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue; }
function with_each(query, cb, root) {
var results = xp(query, root);
for (var i = 0, j = results.snapshotLength; i < j; i++)
cb(results.snapshotItem(i));
}
var unreadLinks = '//img[contains(@src, "firstnew")]/ancestor::a';
var relativeThreadLink = "following::a[1]";
with_each(unreadLinks, function(item) {
xps(relativeThreadLink, item).href = item.href;
});
var newImages = document.getElementsByTagName('img');
for(var curElem = 0; curElem < newImages.length; curElem++){
if(newImages[curElem].src.indexOf("firstnew.gif") != -1){
newImages[curElem].parentNode.parentNode.removeChild(newImages[curElem].parentNode);
}
}