MediaWiki:Common.js
MediaWiki interface page
More actions
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');
}
}
}
});