Created
October 12, 2010 12:58
-
-
Save vrld/622126 to your computer and use it in GitHub Desktop.
This file contains hidden or 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== | |
// @include *love2d.org/forums/viewtopic.php* | |
// ==/UserScript== | |
(function() { | |
var users = []; // the users to hide automatically | |
function getElementsByTagAndClass(tag, cls) { | |
var tags = document.getElementsByTagName(tag); | |
var ret = []; | |
for (i = 0; i < tags.length; ++i) { | |
if (tags[i].className.indexOf(cls) > -1) | |
ret.push(tags[i]); | |
} | |
return ret; | |
} | |
function hider(body, profile, link, author) { | |
return function() { | |
body.style.display = "none"; | |
profile.style.display = "none"; | |
link.onclick = shower(body, profile, link, author); | |
link.innerHTML = "show post ("+author+")"; | |
return false; | |
} | |
} | |
function shower(body, profile, link, author) { | |
return function() { | |
body.style.display = "block"; | |
profile.style.display = "block"; | |
link.onclick = hider(body, profile, link, author); | |
link.innerHTML = "hide post"; | |
return false; | |
} | |
} | |
var posts = getElementsByTagAndClass("div", "post "); | |
for (i = 0; i < posts.length; ++i) { | |
var inner = posts[i].childNodes[1]; | |
var postbody = inner.childNodes[2]; | |
var profile = inner.childNodes[4]; | |
var author = postbody.childNodes[5].childNodes[2].firstChild.innerHTML; | |
if (users.indexOf(author) > -1) { | |
var link = document.createElement("a"); | |
var hide = hider(postbody, profile, link, author); | |
var show = shower(postbody, profile, link, author); | |
hide(); | |
link.onclick = show; | |
link.style.display = "block"; | |
link.style.cssFloat = "right"; | |
link.style.fontSize = "9pt"; | |
link.style.fontWeight = "bold"; | |
inner.insertBefore(link, profile); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment