Jump to content

User:Willy1018/common.js

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Willy1018 (talk | contribs) at 02:46, 3 June 2022. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
importScript('User:Alex 21/script-functions.js');
importScript('User:Alex 21/script-redlinks.js');
// Copied from [[:w:zh:MediaWiki:Gadget-variant-link-fix.js]]
try {
    var ref, loc;
    try {
        ref = new mw.Uri( document.referrer );
    } catch ( e ) {
        ref = new mw.Uri( document.referrer + '/' );
    }
    loc = new mw.Uri( location.href );
    if (/\.google\./.test(ref.host) && loc.host == 'zh.m.wikipedia.org') {
        loc.host = 'zh.wikipedia.org';
        loc.path = loc.path.replace(/^\/zh(-[^/]+)?\//, "/wiki/");
        location.replace(loc.toString());
    }
} catch ( e ) {
}