MediaWiki:Common.js: Difference between revisions
MediaWiki interface page
More actions
Updated VisualEdit button link fix |
No edit summary Tag: Manual revert |
||
| (One intermediate revision by the same user not shown) | |||
(No difference)
| |||
Latest revision as of 22:05, 22 February 2026
/* 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');
}
}
}
});