=== GP Forums Greasemonkey scripts ===
=== You will need ===
* Firefox
* Greasemonkey plugin
=== Installing scripts ===
# Create a file called {{{xxx.user.js}}} - the xxx is unimportant, the .user.js is what denotes the file as a Greasemonkey script.
# Copy and paste the script into that file
#Navigate to wherever you created xxx.user.js, at this point, Greasemonkey will prompt you to install it.
=== Scripts ===
==== Clickherebegone ====
A Greasemonkey script to completely remove all trace of ignored posts on the Gameplanet forums.
**DISCLAIMER:** May break stuff, use at own risk, contains traces of peanuts. Copyright vests in the original author of this work, so if I see it on any BT trackers, I'll send you a catty email. You're scared now, I can tell.
// ==UserScript==
// @name Click Here Be Gone
// @namespace http://cynos.waz.ere
// @description GP specific: Make ignored users go away by modifying CSS display attribute of parent row of ignored post
// @include http://www.gpforums.co.nz/*
// @include http://gpforums.co.nz/*
// ==/UserScript==
var xquery = "//a[contains(@onclick, \"javascript:window.open('/showthread.php?s=&action=showpost&postid=\")]";
var nodes = document.evaluate(xquery, document, null, 6, null);
for (var i = 0; i < nodes.snapshotLength; ++i) {
var n = nodes.snapshotItem(i);
n.parentNode.parentNode.parentNode.parentNode.style.display = "none";
}
===== Usage ======
* Browse forums
* People on your ignore list should vanish completely.
* If any strange things happen while using it, PM Cynos.
==== Topic - Open Discussion ====
Converts the Topic breadcrumb to Open Discussion when browsing the former subforums of OD.
// ==UserScript==
// @name Topen
// @namespace http://cynos.waz.ere
// @description GP specific: Make Topics breadcrumb point to GPOD
// @include http://www.gpforums.co.nz/*
// @include http://gpforums.co.nz/*
// ==/UserScript==
function replaceChild(element, child)
{
//Remove all children nodes.
while (element.hasChildNodes())
{
var curr_child = element.firstChild;
element.removeChild(curr_child);
}
element.appendChild(child);
}
function replaceText(element, text)
{
var textNode = document.createTextNode(text);
replaceChild(element, textNode);
}
var xquery = "//a[@href='/forum/Other-Stuff/?s=']";
/*------Init------*/
var nodes = document.evaluate(xquery, document, null, 6, null);
for (var i = 0; i < nodes.snapshotLength; ++i)
{
var n = nodes.snapshotItem(i);
var prev = null;
var next = null;
if (n.previousSibling) prev = n.previousSibling.nodeValue;
if (n.nextSibling) next = n.nextSibling.nodeValue;
if ((prev && next) && (prev.indexOf("/") > -1 && next.indexOf("/") > -1))
{
replaceText(n, "Open Discussion");
n.href = "/forum/Open-Discussion";
}
}
==== Collapse Topics ====
Makes the Topics (subforums) in GPOD collapsible - it will remember your preference.
// ==UserScript==
// @name Tollapse
// @namespace http://cynos.waz.ere
// @description GP specific: Make Topics collapsible
// @include http://www.gpforums.co.nz/forum/Open-Discussion
// @include http://gpforums.co.nz/forum/Open-Discussion
// ==/UserScript==
function replaceChild(element, child)
{
//Remove all children nodes.
while (element.hasChildNodes())
{
var curr_child = element.firstChild;
element.removeChild(curr_child);
}
element.appendChild(child);
}
function replaceText(element, text)
{
var textNode = document.createTextNode(text);
replaceChild(element, textNode);
}
function toggle()
{
showFlag = !showFlag;
GM_setValue("showFlag", showFlag);
setToggleText();
changeDisplay(showFlag);
return false;
}
function setToggleText()
{
if (showFlag) replaceText(toggleLink, "Click here to hide");
else replaceText(toggleLink, "Click here to show sub-forums");
}
function changeDisplay(show)
{
var dp;
if (show) dp = "table-row";
else dp = "none";
var next_sibling = headingTR.nextSibling;
while (next_sibling)
{
if (next_sibling.style) next_sibling.style.display = dp;
next_sibling = next_sibling.nextSibling;
}
}
var toggleLink;
var showFlag = GM_getValue("showFlag", true);
var xquery = "//a[@href='/forum/Other-Stuff/?s=']";
/*------Init------*/
var nodes = document.evaluate(xquery, document, null, 6, null);
var topic = nodes.snapshotItem(0); //Topic href
var subHeadingDiv = topic.parentNode.parentNode.lastChild;
var headingTR = topic.parentNode.parentNode.parentNode;
var toggleLink = document.createElement("a");
toggleLink.href = "#";
toggleLink.addEventListener('click', function(event){toggle()}, false);
setToggleText();
replaceChild(subHeadingDiv, toggleLink);
changeDisplay(showFlag);
==== Flannel - for when GP is too damn sticky ====
This will add a link to the thread list header to hide stickies - it will remember your preference on a forum by forum basis.
// ==UserScript==
// @name Flannel
// @namespace http://cynos.waz.ere
// @description GP specific - collapses stickies
// @include http://www.gpforums.co.nz/forum/*
// @include http://gpforums.co.nz/forum/*
// ==/UserScript==
function filter(arr, fnc)
{
var new_arr = [];
for (var i = 0; i < arr.length; ++i)
{
var a = arr[i];
if(fnc(a)) new_arr.push(a);
}
return new_arr;
}
function replaceChild(element, child)
{
//Remove all children nodes.
while (element.hasChildNodes())
{
var curr_child = element.firstChild;
element.removeChild(curr_child);
}
element.appendChild(child);
}
function replaceText(element, text)
{
var textNode = document.createTextNode(text);
replaceChild(element, textNode);
}
function showFlag() { return GM_getValue(currentLocation(), true);}
function toggle(location)
{
var show = !showFlag();
GM_setValue(currentLocation(), show);
var stickyCount = changeDisplay(show);
setToggleSpanText(stickyCount);
setToggleLinkText();
return false;
}
function setToggleSpanText(stickyCount)
{
if (showFlag()) replaceText(toggleSpan, "");
else replaceText(toggleSpan, ": " + stickyCount + " hidden stickies");
}
function setToggleLinkText()
{
if (showFlag()) replaceText(toggleLink, "Hide stickies");
else replaceText(toggleLink, "Show stickies");
}
function firstRun()
{
var stickyCount = changeDisplay(showFlag());
setToggleLinkText();
setToggleSpanText(stickyCount);
}
function changeDisplay(showFlag)
{
var dp;
if (showFlag) dp = "table-row";
else dp = "none";
var stickyNodes = document.evaluate("//img[@src='/images/sticky.gif']", document, null, 6, null);
for (var i = 0; i < stickyNodes.snapshotLength; i++)
{
var n = stickyNodes.snapshotItem(i);
var row = n.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
row.style.display = dp;
}
return stickyNodes.snapshotLength;
}
function currentLocation()
{
var loc = new String(document.location).split("?")[0];
if (loc.charAt(loc.length - 1) != "/") loc = loc + "/"; //Need to make sure uris are consistent.
return loc;
}
/*------Init------*/
var ELEMENT_NODE = 1;
var sticky_query = "//img[@src='/images/sticky.gif']";
var toggleSpan;
var toggleLink;
//Check that there's actually stickies to avoid un-necessary DOM manipulation
var stickyNodes = document.evaluate(sticky_query, document, null, 6, null);
if (stickyNodes.snapshotLength > 0)
{
//Modify header
var headerChildren = document.getElementById("cat").childNodes;
//I hate that newlines are nodes
var notTextNodes = filter(headerChildren, function(node){ return node.nodeType == ELEMENT_NODE});
var threadHeader = notTextNodes[0];
//build new elements
toggleLink = document.createElement("a");
toggleLink.href = "#";
toggleLink.addEventListener('click', function(event){toggle(currentLocation()); return false}, false);
toggleSpan = document.createElement("span");
//Add styles to over-ride
toggleLink.style.fontWeight = "normal";
toggleSpan.style.fontWeight = "normal";
toggleSpan.style.fontStyle = "italic";
threadHeader.appendChild(document.createTextNode(" - "));
threadHeader.appendChild(toggleLink);
threadHeader.appendChild(document.createTextNode(" "));
threadHeader.appendChild(toggleSpan);
firstRun();
}
==== Sane Delete ====
This one is for the moderators/admins of GP Forums - it unticks all the boxes in the "Selectively Delete Posts" page, which are all ticked by default.
// ==UserScript==
// @name SaneDelete
// @namespace http://cynos.waz.ere
// @description GP mod specific - untick all boxes in Delete Posts
// @include http://www.gpforums.co.nz/postings.php*
// @include http://gpforums.co.nz/postings.php*
// ==/UserScript==
var xexpression = "//input[starts-with(@name, 'delete')]";
var inps = document.evaluate(xexpression, document, null, 6, null);
for (var i = 0; i < inps.snapshotLength; i++)
{
var n = inps.snapshotItem(i);
n.checked = false;
}