User:Year2000Prob/monobook.js

This is an old revision of this page, as edited by Year2000Prob (talk | contribs) at 01:33, 13 September 2008. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// importScript function. Feel free to copy this into [[Special:Mypage/monobook.js|your own Monobook js]].
window.importScript = function(src) {
  var self = arguments.callee;
  if (arguments.length == 0) {
    var imported = self.imported;
    delete self.imported;
    return imported;
  };
  if (!self.imported) self.imported = [];
  var format = function(wscript, source) {
    return wscript.replace(/\{{3}lang\|([a-z]{2})\}{3}/i, source.indexOf(":") == 2 ? source.substring(0, 2) : "$1")
      .replace("{{{src}}}", encodeURIComponent(source.indexOf(":") == 2 ? source.substring(3, source.length) : source))};
  var attrs;
  if (typeof src == "object") {
    attrs = src;
    src = attrs.src;
    delete attrs.src};
  if (self.imported[src]) return self;
  var script = document.createElement("script");
  script.setAttribute("type", "text/javascript");
  script.setAttribute("src", (self.namespaces && /^\[{2}([^\n\r\t]*?)?\]{2}$/.test(src) ? (function() {
    var scriptId = src.substring(2, src.length - 2), path = format(self.namespaces["#default"] || "{{{src}}}", src);
    for (var ns in self.namespaces) {
      if (scriptId.indexOf(ns + ":") == 0) {
        path = format(self.namespaces[ns], scriptId.substring(ns.length + 1)); break}};
    return path})() : encodeURI(src)));
  if (attrs) {
    if (typeof attrs.onload == "function") {
      if (script.addEventListener) script.addEventListener("load", attrs.onload, true);
      else script.onreadystatechange = function() {
        if (this.readyState == "complete" || this.readyState == 4)
          attrs.onload.apply(this,arguments)}; delete attrs.onload};
    for (var attr in attrs) script.setAttribute(attr, attrs[attr])};
  self.imported[self.imported.length] = document.getElementsByTagName("head")[0].appendChild(script);
  return self};
// End importScript function. Copy below this line at your own risk.

var whichsite = ({ // define whichsite (string: "wp" if on Wikipedia, "hrw" if on HRWiki; "hrfw" if on HRFWiki)
  "http://en.wikipedia.org": "wp",
  "http://www.hrwiki.org": "hrw",
  "http://fanstuff.hrwiki.org": "hrfw",
  "http://www.clamburger.org": "wuw"
})[wgServer] || wgServer;

importScript.namespaces = {"#default": "http://{{{lang|en}}}.wikipedia.org/w/index.php?title={{{src}}}&action=raw&ctype=text/javascript"};

var Y2P = new Object();
importScript({src: "[[User:Year2000Prob/Y2P.MediaWiki.js]]", onload: function() {
  window._onload = window.onload;
  window.onload = function() {
    if (typeof window._onload == "function") window._onload.apply(this, arguments);
    Y2P.AddPortletItem({
      text: "Chat channel",
      url: "irc://irc.freenode.net/" + ({wp:"wikipedia",hrw:"hrwiki",hrfw:"hrwiki-fanstuff",wuw:"wikiuserwiki"})[whichsite],
      id: "n-ircchannels",
      overwrite: (whichsite == "wp" ? null : "n-wikilink3"),
      addTo: (whichsite == "wp" ? "p-interaction" : null)
    })({
      text: "Is this page valid XHTML?",
      url: "http://validator.w3.org/check?uri=" + encodeURIComponent(___location),
      id: "f-valid",
      addTo: "footer"
    })();
    if (wgNamespaceNumber != -1) Y2P.AddPortletItem({
      text: "purge",
      url: wgScript + "?title=" + wgPageName + "&action=purge",
      id: "ca-purge",
      addTo: "p-cactions"
    })();
    if (whichsite == "hrfw") Y2P.AddPortletItem({
      text: "Sysop Alert Button",
      url: "http://alert.clamburger.org/",
      id: "n-alertbutton",
      before: "n-usersguide"
    })();
    if (whichsite != "wp") Y2P.AddPortletItem({
      text: "Wiki User Wiki",
      url: "http://www.clamburger.org/wuw/",
      id: "n-wikilink1.5",
      before: "n-wikilink2"
    })();

    Y2P.ChangeActions({
      "nstab-main": "boring fanstuff",
      "nstab-user": "stupid parson",
      "nstab-project": "don't leave without reading this",
      "nstab-template": "it's just a skeleton, crapface",
      "nstab-reviews": "be an infamous critic",
      "talk": "yap yap yap",
      "edit": "vandalise this page",
      "viewsource": "can't touch this",
      "history": "in 1788, australia was born...",
      "move": "got a better commando name?",
      "watch": "stalk",
      "watching": "adding to list of stalked people...",
      "unwatch": "stop stalking",
      "unwatching": "removing from list of stalked people...",
      "purge": "do not press this"
    });
  };
}})({src: "http://code.jquery.com/jquery-latest.pack.js", onload: function() {
  $(function() {
    if ($("#ca-edit").get(0) && /^(view|purge)$/i.test(wgAction)) {
      if ($("#sectionlink-0").get(0)) $("#sectionlink-0").before("<a class='sectionlink' href='" + $("#ca-edit a").attr("href") + "&section=top'>edit</a>/");
      else $("contentSub").css("display", "block").html(($("contentSub").html() ? $("contentSub").html() + "\t" : "") + "[<a class='sectionlink' href='" + $("#ca-edit a").attr("href") + "&section=top'>edit</a>]");
    };

    $(".portlet:not(#p-personal, #p-cactions) h5").css("cursor", "default").click(function() {
      $(this).parent().find("div.pBody").slideToggle("slow");
    }).parent().find("div.pBody").css("border-left", "none").hide();
    
    if (/^Special\:Recent[Cc]hanges$/.test(wgPageName)) {$("h1.firstHeading").html($("h1.firstHeading").html() + " (<a id='rcUpdate' href='javascript:;'>refresh</a>)");
      $("a#rcUpdate").click(function() {$("#bodyContent ul.special").html("<li>Updating...</li>").load(wgScript + "?title=Special:Recentchanges #bodyContent ul.special li")})};

    // I hope this works with Shadowbox
    $("#bodyContent img").attr("rel", "shadowbox[All images]").each(function() {
      var self = $(this), url = (function() {
        return $("#bodyContent img", $.get(self.attr("href")).responseXML).get(0).getAttribute("src");
      })();
      self.attr("href", url);
    });
  });
}})("http://year2000prob.freehostia.com/wp-content/uploads/shadowbox-2.0.js")();

var wikEdUsing = "(using [[" + (whichsite != "wp" ? "wikipedia:" : "") + "User:Cacycle/wikEd|wikEd]])",
    wikEdShowUsingButton = true,
    wikEdSummaryUsing = "(using [[" + (whichsite != "wp" ? "wikipedia:" : "") + "User:Cacycle/wikEd|wikEd]])",
    wikEdCloseToolbarPreset = true,
    wikEdButtonsOnTop = false,
    wikedScripts = importScript("[[User:Cacycle/diff.js]]")("[[User:Pilaf/livepreview.js]]")("[[User:Cacycle/RegExTypoFix.js]]")("[[User:Cacycle/wikEd.js]]")();

importScript("[[de:Benutzer:ASM/quickedit.js]]")("[[User:Lupin/popups.js]]")(); // import Popups so it'll work globally if possible, instead of just on Wikipedia

importScript({src: "http://mediaplayer.yahoo.com/latest", onload: function(){YAHOO.music.WebPlayer.asyncLoadPlayer()}})();