Jump to content

User:Max/noredlink.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
// <nowiki>
var pageURL = document.URL;
if (pageURL.includes("redlink=1")) {
    if (pageURL.includes("action=edit")) {
        pageURL = pageURL.replace('redlink=1','').replace('action=edit','');
    } else {
        pageURL = pageURL.replace('redlink=1','');
    }
    var match = pageURL.match(/[?&]title=([^&]*)/);
    if (match) {
        var title = decodeURIComponent(match[1]).replace(/ /g, "_");
        var base = pageURL.split('/w/')[0];
        var prettyURL = base + '/wiki/' + title;
        window.location.href = prettyURL;
    } else {
        window.location.href = pageURL;
    }
}
// </nowiki>