使用者:Nikopoley/monobook.js

文出維基大典

註:重取頁面,文方新焉。

  • Firefox / Safari:Shift 並點 重新載入,或合鍵 Ctrl-F5Ctrl-R(Mac 為 ⌘-R)。
  • Google Chrome:Ctrl-Shift-R(Mac為 ⌘-Shift-R)。
  • Internet Explorer:Ctrl 並點 重新整理,或合鍵 Ctrl-F5
  • Opera:須至 Tools → Preferences 清謄本(Mac 為 Opera → Preferences)。
//<div><pre><nowiki>
function updatehook() {
    updatelinks(0);
}

function updatelinks(count) {
    for(i=0;i+count<document.links.length;++i)
    {
	    with(document.links[i+count]) {
	        var url=getupdatedurl(href,location);
	            if(url=="")continue;
		    if(innerHTML==href)
			    innerHTML=url;
		    href=url;
	    }
	    if(i>=100)
	    {
	        setTimeout("updatelinks("+(i+count)+")",1000);
	        return;
	    }
    }
}

function getupdatedurl(href,loc) {
    var domain=getpath1(loc);
    var host=getpath2(loc);
    var h=new String(href);
    if(h==hrefstart(h))
    {
        var url;
        var server=getserver(href);
        if(server=="upload.wikimedia.org")return "";
        if(server=="mail.wikipedia.org")return "";
        if(server=="secure.wikimedia.org") {
            if(getpath1(h)!=domain || getpath2(h)!=host)
                url="https://secure.wikimedia.org/"+domain+"/"+host+"/"+getpath(h);
            else return "/"+getpath(h);
        }
        else
            url=update(h);
        return url;
    }
    else
        return "/"+domain+"/"+host+h;
}

function hrefstart(url) {
    var ret=new String(url);
    var start=/^(\/)(.*)/;
    return ret.replace(start,"$2");
}

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 getpath(url) {
    var ret=new String(url);
    var path3=/^([A-Za-z0-9_]+):\/\/([^\/]*)\/(.*)/;
    return ret.replace(path3,"$3");
}

function update(url) {
    var ret=new String(url);
    var ud=/^http:\/\/([^\.\/]*).(wikimedia|wikipedia|wiktionary|wikibooks|wikiquote|wikisource|wikinews).org\/(.*)/;
    return ret.replace(ud,"https://secure.wikimedia.org/$2/$1/$3");
}

function getserver(url) {
    var ret=new String(url);
    var server=/^([A-Za-z0-9_]+):\/\/([^\/]*)\/(.*)/;
    return ret.replace(server,"$2");
}

if(getserver(location)=="secure.wikimedia.org") {
     addLoadEvent(updatehook);
}//</nowiki></pre></div>
// [[:en:User:Lupin/popups.js]] - please include this line 
// [[:zh:User:笨笨的小B/jstool/popup.js]] - 請保留此行
document.write('<script type="text/javascript" src="' 
             + 'http://zh.wikipedia.org/w/index.php?title=User:%E7%AC%A8%E7%AC%A8%E7%9A%84%E5%B0%8FB/jstool/popups.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
document.write('<script type="text/javascript" src="' 
    + 'http://zh.wikipedia.org/w/index.php?title=User:%E7%AC%A8%E7%AC%A8%E7%9A%84%E5%B0%8FB/jstool/strings-zh.js' 
    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');