跳转到内容

User:Fireattack/common.js

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

这是本页的一个历史版本,由Fireattack留言 | 贡献2024年1月14日 (日) 17:53编辑。这可能和当前版本存在着巨大的差异。

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

mw.loader.load('https://wikiplus-app.smartgslb.com/Main.js');

console.log('[Debug] /common.js enabled!');
console.debug(mw);
console.debug(mw.Uri);

try {
    var ref, loc;

    if (document.referrer) {
        try {
            ref = new URL(document.referrer);
        } catch (e) {
            ref = new URL(document.referrer + '/');
        }
    }
    loc = new URL(location.href);

    if (ref && /\.google\./.test(ref.host) && (loc.host == 'zh.wikipedia.org' || loc.host == 'zh.m.wikipedia.org')) {
        loc.host = 'zh.wikipedia.org';
        loc.pathname = loc.pathname.replace(/^\/zh(-[^/]+)?\//, "/wiki/");
        location.replace(loc.toString());
    }
} catch (e) {
    // Handle any errors here
}