User:Phlip/monobook.js
From Homestar Runner Wiki
(Difference between revisions)
(validate link) |
(they're getting annoying...) |
||
| Line 24: | Line 24: | ||
{ | { | ||
b = getChildType(a[i], "A", 1); | b = getChildType(a[i], "A", 1); | ||
| - | pageUrl = b.href; | + | if (b) |
| + | pageUrl = b.href; | ||
} | } | ||
} | } | ||
| Line 55: | Line 56: | ||
if (window.addEventListener) window.addEventListener("load",addValidateLink,false); | if (window.addEventListener) window.addEventListener("load",addValidateLink,false); | ||
else if (window.attachEvent) window.attachEvent("onload",addValidateLink); | else if (window.attachEvent) window.attachEvent("onload",addValidateLink); | ||
| + | |||
| + | function killfakeusermessage() | ||
| + | { | ||
| + | var a = document.getElementsByTagName('DIV'); | ||
| + | for (var i = 0; i < a.length; i++) | ||
| + | { | ||
| + | if (a[i].className == "usermessage") | ||
| + | { | ||
| + | b = getChildType(a[i], "A", 1); | ||
| + | if (b && b.href != "/index.php/User_talk:Phlip") | ||
| + | a[i].style.background = "inherit"; | ||
| + | } | ||
| + | } | ||
| + | } | ||
Revision as of 13:01, 18 March 2006
function getChildType(node,childtype,index)
{
var c = node.childNodes;
childtype = childtype.toLowerCase();
for (var i = 0; i < c.length; i++)
{
if (c[i].tagName && childtype == c[i].tagName.toLowerCase())
{
index--;
if (index <= 0) return c[i];
}
}
return null;
}
function addValidateLink()
{
// find the print footer, it has a canonical page URL in it
// DON'T use window.location, as it can have tags like ?action=edit and things which will mess us up
var a = document.getElementsByTagName('DIV');
var pageUrl = ""
for (var i = 0; i < a.length; i++)
{
if (a[i].className == "printfooter")
{
b = getChildType(a[i], "A", 1);
if (b)
pageUrl = b.href;
}
}
// create the validation link
a = document.getElementById('p-cactions');
a = getChildType(a, 'ul', 1);
li = document.createElement('li');
li.id = 'ca-valid';
li.style.marginLeft = "1.6em";
a.appendChild(li);
link = document.createElement('a');
link.href = "http://validator.w3.org/check?uri=" + escape(pageUrl);
// link.className = "external" // only works in #bodyContent
link.style.color = "#06F";
/* this messes up the margins and paddings, and breaks hover
link.style.background = "url(/skins/monobook/external.png) center right no-repeat";
link.style.paddingRight = "13px";
link.style.marginRight = "0.8em"; // this used to be in the padding, but we need that for the icon
link.style.marginLeft = "0.8em"; link.style.paddingLeft = "0"; // make symmetrical
*/
li.appendChild(link);
link.appendChild(document.createTextNode('Validate '));
img = document.createElement('img');
img.src = "/skins/monobook/external.png";
link.appendChild(img);
}
// these two lines stolen from [[User:Tom/monobook.js]]
if (window.addEventListener) window.addEventListener("load",addValidateLink,false);
else if (window.attachEvent) window.attachEvent("onload",addValidateLink);
function killfakeusermessage()
{
var a = document.getElementsByTagName('DIV');
for (var i = 0; i < a.length; i++)
{
if (a[i].className == "usermessage")
{
b = getChildType(a[i], "A", 1);
if (b && b.href != "/index.php/User_talk:Phlip")
a[i].style.background = "inherit";
}
}
}
