Toggle menu
1
18
17
345
Emergency Response: Liberty County Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js

MediaWiki interface page
Revision as of 22:04, 22 February 2026 by Lucah1337 (talk | contribs)

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.
/* Any JavaScript here will be loaded for all users on every page load. */

/* Fix VisualEditor button to use pretty URL with ?veaction=edit */
$(function() {
    var $veTab = $('#ca-ve-edit a');
    if ($veTab.length) {
        var currentHref = $veTab.attr('href');
        if (currentHref.includes('index.php') && currentHref.includes('veaction=edit')) {
            var titleMatch = currentHref.match(/title=([^&]+)/);
            if (titleMatch) {
                var title = decodeURIComponent(titleMatch[1]).replace(/ /g, '_');  // Replace spaces with _, leave : and / literal
                var prettyBase = '/' + title;
                $veTab.attr('href', prettyBase + '?veaction=edit');
            }
        }
    }
});

/* Fix diff and permanent links to use pretty URLs without /index.php */
function rewriteToPrettyUrl(href) {
    var urlParams = new URLSearchParams(href.split('?')[1] || '');
    var title = urlParams.get('title');
    if (title) {
        title = decodeURIComponent(title).replace(/ /g, '_'); 
        urlParams.delete('title');
        return '/' + title + (urlParams.toString() ? '?' + urlParams.toString() : '');
    }
    return href;
}

$(function() {
    var $permalink = $('#t-permalink a');
    if ($permalink.length && $permalink.attr('href').includes('index.php')) {
        $permalink.attr('href', rewriteToPrettyUrl($permalink.attr('href')));
    }

    $('.mw-changeslist-date').each(function() {
        var $this = $(this);
        var href = $this.attr('href');
        if (href && href.includes('index.php')) {
            $this.attr('href', rewriteToPrettyUrl(href));
        }
    });

    $('.mw-history-histlinks-current, .mw-history-histlinks-previous').each(function() {
        var $this = $(this);
        var href = $this.attr('href');
        if (href && href.includes('index.php')) {
            $this.attr('href', rewriteToPrettyUrl(href));
        }
    });
});
🍪 Cookies help us deliver our services. By using our site, you agree to our use of cookies.