User:Year2000Prob/monobook.js: Difference between revisions

Content deleted Content added
No edit summary
I hope this new formula works.
Line 9:
if (!self.imported) self.imported = [];
var format = function(wscript, source) {
var lang, src;
return wscript.replace(/\{{3}lang\|([a-z]{2})\}{3}/i, source.indexOf(":") == 2 ? source.substring(0, 2) : "$1")
return [wscript.replace(/\{{3}src(?:\|(.+)\|(.+))?\}{3}/, function(m) {
.replace("{{{src}}}", encodeURIComponent(source.indexOf(":") == 2 ? source.substring(3, source.length) : source).replace(/\s|[\.%]20/g, "_"))};
src = m.length == 1 ? source : source.replace(new RegExp("^" + m[1] + "$"), m[2]);
if (/^([a-z]\-[A-Za-z]|[a-z])\:/.test(src)) {
var n = src.match(/^([a-z]\-[A-Za-z]|[a-z])\:/);
lang = n[1];
src = src.substr(n[0].length);
};
return encodeURIComponent(src.replace(" ", "_"));
return wscript}).replace(/\{{3}lang\|([a-z]{2})\}{3}/i, source.indexOf(":")lang == 2 ? source.substring(0, 2) :|| "$1"), src]};
var attrs;
if (typeof src == "object") {
Line 19 ⟶ 27:
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.setAttribute("src", (self.namespaces && /^\[{2}([^\n\r\t]*?)(\|[^\n\r\t]*?)?\]{2}$/.test(src) ? (function() {
var path_f = format(self.namespaces["#default"] || "{{{src}}}", scriptIdsrc), path = _f[0], source = _f[1];
var scriptId = src.match(/^\[{2}([^\n\r\t]+)(\|[^\n\r\t]*?)?\]{2}$/)[1],
path = format(self.namespaces["#default"] || "{{{src}}}", scriptId);
for (var ns in self.namespaces) {
if (scriptIdsource.indexOf(ns + ":") == 0) {
path_f = format(self.namespaces[ns], scriptIdsrc.substring(ns.length + 1)); break}};
path = _f[0]; source = _f[1]; break}};
return path})() : encodeURI(src)));
if (attrs) {
Line 44 ⟶ 52:
})[wgServer] || wgServer;
 
importScript.namespaces = {"#default": "http://{{{lang|en}}}.wikipedia.org/w/index.php?title={{{src|\\[{2}([^\\n\\r\\t]+)(\\|[^\\n\\r\\t]*?)?\\]{2}|$1}}}&action=raw&ctype=text/javascript"};
 
var Y2P = new Object();