User:Phlip/monobook.js

From Homestar Runner Wiki

< User:Phlip(Difference between revisions)
Jump to: navigation, search
(they're getting annoying...)
(to make censoring easier)
 
(includes 4 intermediate revisions)
Line 1: Line 1:
-
function getChildType(node,childtype,index)
+
// include utility functions
 +
document.write('<script type="text/javascript" src="/index.php?title=User:Phlip/utilities.js&amp;action=raw&amp;ctype=text/javascript&amp;dontcountme=s"></script>');
 +
 
 +
function dostuff()
{
{
-
   var c = node.childNodes;
+
   with (utilities)
-
  childtype = childtype.toLowerCase();
+
-
  for (var i = 0; i < c.length; i++)
+
   {
   {
-
     if (c[i].tagName && childtype == c[i].tagName.toLowerCase())
+
     addMonobookTab("http://validator.w3.org/check?uri=" + escape(getArticleURL()), "Validate", true)
 +
    addMonobookBottomTabs()
 +
    if (getArticleNamespace() == 2 || getArticleNamespace() == 3)
     {
     {
-
       index--;
+
       var username = getArticleTitle();
-
       if (index <= 0) return c[i];
+
      var i = username.indexOf('/')
 +
       if (i >= 0)
 +
        username = username.substr(0, i);
 +
      addMonobookNavboxLink(localurl("Contributions/" + username, -1), "Contribs", "tb");
 +
      addMonobookNavboxLink(localurl("Log", -1, "user=" + username), "Show Logs (user)", "tb");
 +
      addMonobookNavboxLink(localurl("Log", -1, "page=User:" + username), "Show Logs (target)", "tb");
     }
     }
   }
   }
-
  return null;
 
}
}
-
function addValidateLink()
+
if (window.addEventListener) window.addEventListener("load",dostuff,false);
 +
else if (window.attachEvent) window.attachEvent("onload",dostuff);
 +
 
 +
function killfakeusermessage()
{
{
-
  // 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 a = document.getElementsByTagName('DIV');
-
  var pageUrl = ""
 
   for (var i = 0; i < a.length; i++)
   for (var i = 0; i < a.length; i++)
   {
   {
-
     if (a[i].className == "printfooter")
+
     if (a[i].className == "usermessage")
     {
     {
       b = getChildType(a[i], "A", 1);
       b = getChildType(a[i], "A", 1);
-
       if (b)
+
       if (b && b.href != "/index.php/User_talk:Phlip"
-
        pageUrl = b.href;
+
            && b.href != "http://hrwiki.org/index.php/User_talk:Phlip"
 +
            && b.href != "http://www.hrwiki.org/index.php/User_talk:Phlip")
 +
        a[i].style.background = "inherit";
     }
     }
   }
   }
-
 
-
  // 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",killfakeusermessage,false);
-
if (window.addEventListener) window.addEventListener("load",addValidateLink,false);
+
else if (window.attachEvent) window.attachEvent("onload",killfakeusermessage);
-
else if (window.attachEvent) window.attachEvent("onload",addValidateLink);
+
-
function killfakeusermessage()
+
mwCustomEditButtons[mwCustomEditButtons.length] =
{
{
-
   var a = document.getElementsByTagName('DIV');
+
   "imageFile": 'http://forum.hrwiki.org/images/smiles/emoblush.gif',
-
   for (var i = 0; i < a.length; i++)
+
   "speedTip": 'Mark a swear',
-
   {
+
   "tagOpen": '{{{swear|',
-
    if (a[i].className == "usermessage")
+
  "tagClose": '}}}',
-
    {
+
   "sampleText": ''
-
      b = getChildType(a[i], "A", 1);
+
-
      if (b && b.href != "/index.php/User_talk:Phlip")
+
-
        a[i].style.background = "inherit";
+
-
    }
+
-
   }
+
}
}

Current revision as of 02:29, 10 May 2007

 // include utility functions
 document.write('<script type="text/javascript" src="/index.php?title=User:Phlip/utilities.js&amp;action=raw&amp;ctype=text/javascript&amp;dontcountme=s"></script>');

function dostuff()
{
  with (utilities)
  {
    addMonobookTab("http://validator.w3.org/check?uri=" + escape(getArticleURL()), "Validate", true)
    addMonobookBottomTabs()
    if (getArticleNamespace() == 2 || getArticleNamespace() == 3)
    {
      var username = getArticleTitle();
      var i = username.indexOf('/')
      if (i >= 0)
        username = username.substr(0, i);
      addMonobookNavboxLink(localurl("Contributions/" + username, -1), "Contribs", "tb");
      addMonobookNavboxLink(localurl("Log", -1, "user=" + username), "Show Logs (user)", "tb");
      addMonobookNavboxLink(localurl("Log", -1, "page=User:" + username), "Show Logs (target)", "tb");
    }
  }
}
if (window.addEventListener) window.addEventListener("load",dostuff,false);
else if (window.attachEvent) window.attachEvent("onload",dostuff);

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"
            && b.href != "http://hrwiki.org/index.php/User_talk:Phlip"
            && b.href != "http://www.hrwiki.org/index.php/User_talk:Phlip")
        a[i].style.background = "inherit";
    }
  }
}

if (window.addEventListener) window.addEventListener("load",killfakeusermessage,false);
else if (window.attachEvent) window.attachEvent("onload",killfakeusermessage);

mwCustomEditButtons[mwCustomEditButtons.length] = 
{
  "imageFile": 'http://forum.hrwiki.org/images/smiles/emoblush.gif',
  "speedTip": 'Mark a swear',
  "tagOpen": '{{{swear|',
  "tagClose": '}}}',
  "sampleText": ''
}