“MediaWiki:Gadget-site-shared.js”的版本间差异

添加169字节 、​ 2021年1月24日 (日) 12:14
无编辑摘要
action = mw.config.get('wgAction'),
editable = mw.config.get( 'wgIsProbablyEditable' ),
username = mw.config.get('wgUserName'),
$body = $('body');
 
/**
* @Function: 点击其他用户主页面的红链不会进入创建页面
* @Dependencies: mediawiki.Uriutil, mediawiki.Title
*/
$content.find( '.new' ).attr('href', function(i, val) {
const uriquery = new mw.Uriutil.getParamValue('title', val ),;
if (!query) { return; } // 特殊页面
const title = new mw.Title( uri.query.title ), // 借助mediawiki.Title规范用户名格式
username = title.getMainText();
// 不处理讨论页或是子页面 name = title.getMainText();
// 不处理非用户空间或用户子页面
if (title.namespace != 2 || usernamename.includes( '/' ) || usernamename == mw.config.get('wgUserName')username) { return; }
return title.getUrl();
});
/**
if (['edit', 'submit'].includes(action) && !editable && $('.editRequest').length == 1) {
* @Function: 生成完整的编辑请求链接
var ele = $('.editRequest > a'),
* @Dependencies: mediawiki.util, mediawiki.Title
href = new mw.Uri(ele.attr('href')),
*/
const var $ele = $('.editRequest > a'),;
if (['edit', 'submit'].includes(action) && !editable && $('.editRequest')ele.length == 1) {
var href = new mw.Uri($ele.attr('href')),
date = new Date();
href.query.preloadtitle = '编辑请求' + ' - ' + mw.config.get('wgUserName')username + ' (' + date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate() + ')';
$ele.attr('href', href.toString());
}
16,874

个编辑