User:Neo-Jay/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
The accompanying .css page for this skin is at User:Neo-Jay/monobook.css. |
//<div><pre><nowiki>
function MyaddLoadEvent(func)
{
if (window.addEventListener)
window.addEventListener("load", func, false);
else if (window.attachEvent)
window.attachEvent("onload", func);
}
function checkpath(url) {
var reg=/^\/w(\/|iki\/).*/;
if(reg.test(url))return true;
}
function getpathfromurl(url) {
var ret=new String(url);
var path3=/^([A-Za-z0-9_]+):\/\/([^\/]*)\/(.*)/;
return ret.replace(path3,"$3");
}
function getpath(olink){
if(is_gecko){
return olink.pathname;
}
var reg=/^.*href="([^"]+)".*$/;
return getpathfromurl(olink.outerHTML.replace(reg,"$1"));
}
function getpath1(url) {
var ret=new String(url);
var path1=/^([A-Za-z0-9_]+):\/\/([^\/]*)\/([^\/]*)\/(.*)/;
var tmp=new String(url);
ret=ret.replace(path1,"$3");
if(ret==tmp) {
return ret.replace(/^([A-Za-z0-9_]+):\/\/([^\/]*)\/(.*)/,"$3");
}
return ret;
}
function getpath2(url) {
var ret=new String(url);
var path2=/^([A-Za-z0-9_]+):\/\/([^\/]*)\/([^\/]*)\/([^\/]*)\/(.*)/;
var tmp=new String(url);
ret=ret.replace(path2,"$4");
if(ret==tmp){
return ret.replace(/^([A-Za-z0-9_]+):\/\/([^\/]*)\/([^\/]*)\/(.*)/,"$4");
};
return ret;
}
function update(url) {
var ret=new String(url);
var ud=/^http:\/\/([^\.\/]*).(wikimedia|wikipedia|wiktionary|wikibooks|wikiquote|wikisource|wikinews).org\/(.*)/;
return ret.replace(ud,"http://secure.wikimedia.org/$2/$1/$3");
}
function updateurl(olink) {
if(is_gecko) {
return update(olink.href);
}
var reg=/^.*href="([^"]+)".*$/;
return update(olink.outerHTML.replace(reg,"$1"));
}
function fixup(obj) {
var path=getpath(obj);
if(obj.protocol=="https:" && checkpath(path))
obj.href="/"+getpath1(location)+"/"+getpath2(location)+path;
else
obj.href=updateurl(obj);
obj.onmouseover=obj.oldfun;
}
function checklink(olink) {
if(olink.hostname=="up.wiki.x.io")return;
if(olink.hostname=="mail.wiki.x.io")return;
if(olink.protocol=="https:") {
if(olink.hostname=="secure.wikimedia.org") {
if(!checkpath(olink.pathname))return;
}
}
olink.oldfun=olink.onmouseover;
if(olink.oldfun) {
olink.onmouseover=function(){this.oldfun();fixup(this);}
}
else olink.onmouseover=function(){fixup(this);}
}
function updatehook() {
for(i=0;i+document.links.length;++i) {
checklink(document.links[i]);
}
}
if(location.protocol=="https:") {
MyaddLoadEvent(updatehook);
}//</nowiki></pre></div>