跳转到内容

User:Liangent/Scripts/ServerSwitch.uncompressed.js

维基百科,自由的百科全书

注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。

jQuery(function() {
    if (window.wgCustomServer === undefined) return;
    var replaces = [];
    if (wgCustomServer.upload !== undefined) {
        replaces.push([
            /^(url\(\s*["']?)?http:\/\/upload\.wikimedia\.org\//,
            '$1' + wgCustomServer.upload + '/'
        ]);
    }
    if (replaces.length == 0) return;
    jQuery.each(replaces, function() {
        var replacement = this;
        jQuery('*[src]').add('*[style]').each(function() {
            if (this.src && jQuery.isFunction(this.src.replace)) {
                this.src = this.src.replace(replacement[0], replacement[1]);
            }
            if (this.style) {
                for (var name in this.style) {
                    if (this.style[name] && jQuery.isFunction(this.style[name].replace)) {
                        this.style[name] = this.style[name].replace(replacement[0], replacement[1]);
                    }
                }
            }
        });
    });
});