注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的更改的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5。
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
if (mw.config.get('wgPageName') === '首页'){
importScript( 'MediaWiki:Mainpage.js' );
} else {
}
$(document).ready(function() {
// 查找所有以 /index.php? 开头的链接
$('a[href^="/index.php?"]').each(function() {
var href = $(this).attr('href');
// 判断链接中是否含有 action=veedit 参数
if (href.indexOf('action=veedit') !== -1) {
// 通过正则匹配提取 title 参数的值
var titleMatch = href.match(/(?:\?|&)title=([^&]+)/);
if (titleMatch && titleMatch[1]) {
var title = decodeURIComponent(titleMatch[1]);
// 构造新的短链接形式:/w/veedit/Page_title
var newHref = '/w/veedit/' + encodeURIComponent(title);
$(this).attr('href', newHref);
}
}
});
});