There are 2 previous versions of this script.
// ==UserScript==
// @name TNN_JS_Fixer
// @namespace davidsev
// @description Fixes some JS screwups in the current version of TNN.
// @include http*://thenethernet.com*
// @include http*://*.thenethernet.com*
// ==/UserScript==
window.addEventListener("load", function()
{
fixLinks();
document.addEventListener("DOMNodeInserted", fixLinks, false);
}, false);
function toFix(node)
{
// Pmail delete.
if (node.textContent == "Delete")
return(true);
// Tag delete.
if (node.parentNode.className == "tagDelete collapsed")
return(true);
// Lightpost delete.
if (node.getAttribute("onclick").match("/missions/remove_lightpost/"))
return(true);
return(false);
}
function fixLinks()
{
var allNodes = document.getElementsByTagName("*");
var count = 0;
for (var j = 0; j < allNodes.length; j++)
{
if(allNodes[j].getAttribute("onclick") && toFix(allNodes[j]))
{
allNodes[j].setAttribute("GM_DavidSev_onclick", allNodes[j].getAttribute("onclick"))
allNodes[j].removeAttribute("onclick");
allNodes[j].addEventListener("click", clicky, false);
count++;
}
}
GM_log("Attempted to fix " + count + " nodes.");
}
function clicky(e)
{
e.preventDefault();
var code = this.getAttribute("GM_DavidSev_onclick").replace(/return[^;]*;/g, "");
GM_log("Event handler for " + code);
//this.eval(code);
var jQuery = unsafeWindow.jQuery;
//alert(jQuery);
(function(){
eval(code);
}).call(unsafeWindow);
GM_log("Eval done");
return;
}
