Difference between revisions of "User:JeevesMkII/monobook.js"

From RationalWiki
Jump to navigation Jump to search
m (this time?)
(fix code to away crappy wigos in the new format, each vote with its own table for some bizarre reason)
Line 14: Line 14:
  
 
function awayCrappyWigos() {
 
function awayCrappyWigos() {
var divs = document.getElementsByTagName("div");
+
var divs = document.getElementsByTagName("span");
 
for (var i = 0; i < divs.length; ++i) {
 
for (var i = 0; i < divs.length; ++i) {
 
if (divs[i].id.substring(0, 4) == "wigo") {
 
if (divs[i].id.substring(0, 4) == "wigo") {
 
var voteCount = parseInt(divs[i].innerHTML);
 
var voteCount = parseInt(divs[i].innerHTML);
// traverse up the tree thrice, and check we've hit the table row
+
// traverse up the tree four times, and check we've hit the table
var row = divs[i].parentNode.parentNode.parentNode;
+
var row = divs[i].parentNode.parentNode.parentNode.parentNode;
if (row.tagName == "TR" && voteCount <= wigoThreshold) {
+
if (row.tagName == "TABLE" && voteCount <= wigoThreshold) {
 
row.style.display = "none";
 
row.style.display = "none";
 
}
 
}

Revision as of 10:27, 28 April 2009

/*function awayPeskyFloatingBox() {
	var divs = document.getElementsByTagName("div");
	for (var i = 0; i < divs.length; ++i) {
		if (hasClass(divs[i], "plainlinks")) {
			divs[i].style.display = "none";
		}
	}
}

addOnloadHook(awayPeskyFloatingBox);
*/

var wigoThreshold = -5;

function awayCrappyWigos() {
	var divs = document.getElementsByTagName("span");
	for (var i = 0; i < divs.length; ++i) {
		if (divs[i].id.substring(0, 4) == "wigo") {
			var voteCount = parseInt(divs[i].innerHTML);
			// traverse up the tree four times, and check we've hit the table
			var row = divs[i].parentNode.parentNode.parentNode.parentNode;
			if (row.tagName == "TABLE" && voteCount <= wigoThreshold) {
				row.style.display = "none";
			}
		}
	}
}

addOnloadHook(awayCrappyWigos);