User:Year2000Prob/monobook.js: Difference between revisions

Content deleted Content added
No edit summary
m Maintenance: Replacing legacy global variable (phab:T72470)
 
(46 intermediate revisions by one other user not shown)
Line 2:
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 = [];
if (arguments.length == 0) {
var attrs;
var imported = self.imported;
self.imported.length = 0;
return imported;
};
var attrs, format = function(ns,src){return typeof self.namespaces[ns]=="function"?self.namespaces[ns](src):(self.namespaces[ns]||mw.config.get('wgServer')+mw.config.get('wgScript')+"?title={{{src}}}&action=raw&ctype=text/javascript").replace("{{{src}}}", src)};
if (typeof src == "object") {
attrs = src;
Line 14:
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("reltype", "stylesheettext/javascript");
script.setAttribute("typesrc", "text/"(self.namespaces +&& /^\[{2}(isCSS[^\n\r\t]+)\]{2}$/.test(src) ? "css"(function() : "javascript"));{
var source = src.match(/^\[{2}([^\n\r\t]+)\]{2}$/)[1],
script.setAttribute((isCSS ? "href" : "src"), (self.namespaces && !/^https?\:\/\//.test(src) ? (function() {
var path = format(self.namespaces["#default"] || "{{{src}}}", src, isCSSsource);
for (var ns in self.namespaces) {
if (srcsource.indexOf(ns + ":") == 0) {
path = format(self.namespaces[ns], srcsource.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 hattrs.onload};
for (var attr in attrs) script.setAttribute(attr, attrs[attr])};
self.imported[self.imported.length] = document.getElementsByTagName("head")[0].appendChild(script);
Line 34:
// End importScript function. Copy below this line at your own risk.
 
var MWVersion = (function(z) {
var whichsite; // define whichsite (string: "wp" if on Wikipedia, "hrw" if on HRWiki; "hrfw" if on HRFWiki)
var a = z.match(/([0-9])\.([0-9]*)/);
switch (wgServer) {
var b = a[2];
case "http://en.wikipedia.org":whichsite="wp";break;
if (b.length == 1) b = "0" + b;
case "http://www.hrwiki.org":whichsite="hrw";break;
return Number(a[1] + "." + b);
case "http://fanstuff.hrwiki.org":whichsite="hrfw";break;
})(wgVersion), 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://wuw.clamburger.org": "wuw"
})[wgServer] || "null";
 
importScript.namespaces = {"#default": "http://{{{lang|en}}}.wikipedia.org/w/index.php?title={{{function(src}}}&action=raw&ctype=text/{{) {isCSS|css|javascript}}}"};
var v = (function(s) {
var n = s.match(/^([a-z]{2})\:/), l = n[1];
s = s.substr(n[0].length); return [s, l];
})(src); return "http://" + v[1] + ".wikipedia.org/w/index.php?title=" + encodeURIComponent(v[0].replace(" ", "_")) + "&action=raw&ctype=text/javascript"}};
 
var Y2P = new Object();
importScript({src: "[[en:User:Year2000Prob/Y2P.MediaWiki.js]]", onload: function() {
window._onload = window.onload;
Y2P.AddPortletItem({
window.onload = function() {
text: "Chat channels",
if (typeof window._onload == "function") window._onload.apply(this, arguments);
url: "irc://irc.freenode.net/" + (whichsite == "wp" ? "wikipedia" : "hrwiki,hrwiki-fanstuff"),
Y2P.AddPortletItem({
id: "n-ircchannels",
text: "Chat channel",
overwrite: (whichsite == "wp" ? null : "n-wikilink3"),
url: "irc://irc.freenode.net/" + ({wp:"wikipedia",hrw:"hrwiki",hrfw:"hrwiki-fanstuff",wuw:"wikiuserwiki"})[whichsite],
addTo: (whichsite == "wp" ? "p-interaction" : null)
id: "n-ircchannels",
})({
overwrite: (whichsite == "wp" ? null : "n-wikilink3"),
text: "Is this page valid XHTML?",
addTo: (whichsite == "wp" ? "p-interaction" : null)
url: "http://validator.w3.org/check?uri=" + encodeURIComponent(___location),
id: "f-valid",})({
text: "Is this page valid XHTML?",
addTo: "footer"
url: "http://validator.w3.org/check?uri=" + encodeURIComponent(___location),
})();
id: "f-valid",
if (wgNamespaceNumber != -1) Y2P.AddPortletItem({
text addTo: "purgefooter",
})();
url: wgScript + "?title=" + wgPageName + "&action=purge",
if (wgNamespaceNumber != -1) Y2P.AddPortletItem({
id: "ca-purge",
addTo text: "p-cactionspurge",
url: wgScript + "?title=" + wgPageName + "&action=purge",
})();
id: "ca-purge",
if (whichsite == "hrfw") Y2P.AddPortletItem({
addTo: "p-cactions"
text: "Sysop Alert Button",
})();
url: "http://alert.clamburger.org/",
if (whichsite == ("hrfw"||"wuw")) Y2P.AddPortletItem({
id: "n-alertbutton",
before text: "n-usersguideSysop Alert Button",
url: "http://alert.clamburger.org/",
})();
id: "n-alertbutton",
if (whichsite != "wp") Y2P.AddPortletItem({
before: "n-usersguide"
text: "Wiki User Wiki",
})();
url: "http://www.clamburger.org/wuw/",
if (whichsite == ("hrw"||"hrfw")) Y2P.AddPortletItem({
id: "n-wikilink1.5",
before text: "n-wikilink2Wiki User Wiki",
url: "http://www.clamburger.org/wuw/",
})();
id: "n-wikilink1.5",
before: "n-wikilink2"
})();
 
Y2P.ChangeActions({
"nstab-main": "boring fanstuffpage",
"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>]");
};
 
var sidebar = $(".portlet:not(#p-personal, #p-cactions, #p-logo) h5")div.css("cursor", "defaultpBody").click(function() {;
$sidebar.css(this"border-left", "none").parent().find("div.pBodyh5").slideTogglecss("slowcursor", "default");
// The click event is made obsolete by MediaWiki 1.14
}).parent().find("div.pBody").hide();
if (MWVersion == 1.14) sidebar.hide().parent().find("h5").click(function() {
 
$(this).parent().find("div.pBody").slideToggle("slow")});
if (wgPageName == "Special:Recentchanges") {
window.setInterval(function() {
if (/^Special\:(Recent[Cc]hanges|Watchlist)$/.test(wgPageName)) {
$("#bodyContent ul.special").load(wgScript + "?title=Special:Recentchanges #bodyContent ul.special li");
$("h1.firstHeading").html($("h1.firstHeading").html() + " (<a id='rcUpdate' href='javascript:;'>refresh</a>)");
}, 15000);
$("a#rcUpdate").click(function() {
 
if (whichsite !=$("#bodyContent ul.special"wp).html("<li>Updating...</li>") $.load(wgScript + "?title=" + wgPageName + " #bodyContent ul.special li").each(function(i) {;
$("#bodyContent div:has(span#RCM0)").html("<span>Updating...</span>").load(wgScript + "?title=" + wgPageName + " #bodyContent div:has(span#RCM0) span");
$(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;,
wikedScripts = importScript("[[en:User:Cacycle/diff.js]]")("[[en:User:Pilaf/livepreview.js]]")("[[en:User:Cacycle/RegExTypoFix.js]]")("[[en:User:Cacycle/wikEd.js]]")();
 
importScript("[[de:Benutzer:ASM/quickedit.js]]")("[[en:User:Lupin/popups.js]]")(); // import Popups so it'll work globally if possible, instead of just on Wikipedia
 
var ywmpScript = importScript({src: "http://mediaplayer.yahoo.com/latest", onload: function(){YAHOO.music.WebPlayer.asyncLoadPlayer()}})[0];