更多操作
无编辑摘要 标签:已被回退 |
标签:撤销 |
||
第5行: | 第5行: | ||
} | } | ||
$(document).ready(function() { | mw.loader.using('mediawiki.Uri', function () { | ||
$(document).ready(function () { | |||
$('a').each(function () { | |||
var href = $(this).attr('href'); | |||
if (href && href.indexOf('veaction=edit') !== -1) { | |||
// 解析链接 | |||
var uri = new mw.Uri(href); | |||
if (uri.query.veaction === 'edit') { | |||
// 将参数替换为 action=veedit | |||
delete uri.query.veaction; | |||
uri.query.action = 'veedit'; | |||
// 构造新的 URL(去除 index.php 部分,让它符合短链接结构) | |||
// 假设正常页面链接结构为 /wiki/Page_title,因此这里用 veedit 替换 edit 的部分 | |||
var newHref = '/w/veedit/' + encodeURIComponent(uri.query.title || uri.path); | |||
// 保留其他查询参数 | |||
var params = []; | |||
$.each(uri.query, function (key, val) { | |||
if (key !== 'title') { | |||
params.push(key + '=' + encodeURIComponent(val)); | |||
} | |||
}); | |||
if (params.length) { | |||
newHref += '?' + params.join('&'); | |||
} | |||
// 更新链接 | |||
$(this).attr('href', newHref); | |||
} | |||
} | } | ||
} | }); | ||
}); | }); | ||
}); | }); |
2025年5月16日 (五) 12:27的版本
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
if (mw.config.get('wgPageName') === '首页'){
importScript( 'MediaWiki:Mainpage.js' );
} else {
}
mw.loader.using('mediawiki.Uri', function () {
$(document).ready(function () {
$('a').each(function () {
var href = $(this).attr('href');
if (href && href.indexOf('veaction=edit') !== -1) {
// 解析链接
var uri = new mw.Uri(href);
if (uri.query.veaction === 'edit') {
// 将参数替换为 action=veedit
delete uri.query.veaction;
uri.query.action = 'veedit';
// 构造新的 URL(去除 index.php 部分,让它符合短链接结构)
// 假设正常页面链接结构为 /wiki/Page_title,因此这里用 veedit 替换 edit 的部分
var newHref = '/w/veedit/' + encodeURIComponent(uri.query.title || uri.path);
// 保留其他查询参数
var params = [];
$.each(uri.query, function (key, val) {
if (key !== 'title') {
params.push(key + '=' + encodeURIComponent(val));
}
});
if (params.length) {
newHref += '?' + params.join('&');
}
// 更新链接
$(this).attr('href', newHref);
}
}
});
});
});