User:Year2000Prob/monobook.js

This is an old revision of this page, as edited by Year2000Prob (talk | contribs) at 08:21, 16 August 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;
  var format = function(wscript, src, isCSS) {
    return wscript.replace(/\{{3}lang\|([a-z]{2})\}{3}/i, src.indexOf(":") == 2 ? src.substring(0, 2) : "$1")
      .replace(/\{{3}iscss\|([^\|]*)\|([^\}]*)\}{3}/gi, function(match) {
         return (isCSS ? match[1] : match[2]).replace("{{!}}", "|");
      }).replace("{{{src}}}", src.indexOf(":") == 2 ? src.substring(3, src.length) : src)};
  if (!self.imported) self.imported = [];
  var attrs;
  if (typeof src == "object") {
    attrs = src;
    src = attrs.src;
    delete attrs.src};
  if (self.imported[src]) return self;
  var isCSS = attrs ? attrs.isCSS : (src.indexOf(".css") != -1), script = document.createElement(isCSS ? "link" : "script");
  if (isCSS) script.setAttribute("rel", "stylesheet");
  script.setAttribute("type", "text/" + (isCSS ? "css" : "javascript"));
  script.setAttribute((isCSS ? "href" : "src"), (self.namespaces && !/^https?\:\/\//.test(src) ? (function() {
    var path = format(self.namespaces["#default"] || "{{{src}}}", src, isCSS);
    for (var ns in self.namespaces) {
      if (src.indexOf(ns + ":") == 0) {
        path = format(self.namespaces[ns], src.substring(ns.length + 1), isCSS); break}};
    return path})() : encodeURI(src)));
  if (attrs) {
    if (typeof attrs.onload == "function" && !isCSS) {
      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 h.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)
switch (wgServer) {
  case "http://en.wikipedia.org":whichsite="wp";break;
  case "http://www.hrwiki.org":whichsite="hrw";break;
  case "http://fanstuff.hrwiki.org":whichsite="hrfw";break;
};

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

var Y2P = new Object();
importScript({src: "User:Year2000Prob/Y2P.MediaWiki.js", onload: function() {
  Y2P.AddPortletItem({
    text: "Chat channels",
    url: "irc://irc.freenode.net/" + (whichsite == "wp" ? "wikipedia" : "hrwiki,hrwiki-fanstuff"),
    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").hide();

    if (wgPageName == "Special:Recentchanges") {
      window.setInterval(function() {
        $("#bodyContent ul.special").load(wgScript + "?title=Special:Recentchanges #bodyContent ul.special li");
      }, 15000);

      if (whichsite != "wp") $("#bodyContent ul.special li").each(function(i) {
        $(this.getElementsByTagName("a").filter(function(a) {
          return a.class == "new" && new RegExp("^(" + wgServer + ")?" + wgArticlePath.replace("%1", "User_talk:") + "(.*)$", "i").test(a.href);
        })).click(function() {
          var prelimresp = $.get(this.href + "?action=submit");
          var edittime = prelimresp.responseText.match(/\<input type='hidden' value="(\d+)" name="wpEdittime" \/\>/)[1];
          var edittoken = prelimresp.responseText.match(/\<input type='hidden' value="([^"]+)" name="wpEditToken" \/\>/)[1];
          $.post(this.href + "?action=submit", {
            "wpEdittime": edittime,
            "wpEditToken": escape(edittoken).replace(/\+/g, "%2B"),
            "wpTextbox1": "{{{subst:welcome|~" + "~" + "~}}}",
            "wpSummary": "welcome!",
            "wpSection": "",
            "wpSave": "Save+page"
          });
        });
      });
    };
  });
}});

var wikEdUsing = "(using [[" + (whichsite != "wp" ? "wikipedia:" : "") + "User:Cacycle/wikEd|wikEd]])",
    wikEdShowUsingButton = true,
    wikEdSummaryUsing = "(using [[" + (whichsite != "wp" ? "wikipedia:" : "") + "User:Cacycle/wikEd|wikEd]])",
    wikEdFullScreenModePreset = true,
    wikEdCloseToolbarPreset = true,
    wikEdButtonsOnTop = false;
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]]");

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