MediaWiki:Gadget-edit0.js:修订间差异

删除的内容 添加的内容
创建页面,内容为“// en:MediaWiki:Gadget-edittop.js // ********************************************************************** // ** ***WARNING GLOBAL GADGET FILE*** ** // ** changes to this file affect many users. ** // ** please discuss on the talk page before editing ** // ** ** // ******************************************************…”
 
无编辑摘要
 
第1行:
// [[en:MediaWiki:Gadget-edittop.js]]
 
// **********************************************************************
// ** ***WARNING GLOBAL GADGET FILE*** **
// ** changes to this file affect many users. **
// ** please discuss on the talk page before editing **
// ** **
// [[en:上游基准:enwiki MediaWiki:Gadget-edittop.js]] 2026-05-13 最新版
// 本地化改良:仅保留中英日三语种,新增按钮显示文字+自动编辑摘要,保留全部官方兼容修复
// **********************************************************************
// Imported from [[:en:User:Alex Smotrov/edittop.js]], version as of: 2007-06-19T04:28:52
// Updated from [[:en:User:TheDJ/Gadget-edittop.js]], version as of: 2009-04-28T11:54:22
// Modified toLocalized only supportfor Chinese (zh, /zh-cn, /zh-hans/zh-hant/en/ja, hant)add with hanslead asedit default.summary
 
if ($.inArray(mw.config.get('wgAction'), ['view', 'purge']) !== -1 && mw.config.get('wgNamespaceNumber') >= 0) {
$(function edittop_hook() {
var localtitles = {
'zh': '编辑首段', // 通用中文
'zh-cn': '编辑首段', // 中国大陆简体
'hans': '编辑首段', // 简体中文(通用,作为默认)
'hant': '編輯首段' // 繁体中文(通用)
};
 
if (
var our_content = $('#content, #mw_content').first();
[ 'view', 'purge' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 &&
var span1 = our_content.find('span.mw-editsection:not(.plainlinks)').first();
mw.config.get( 'wgNamespaceNumber' ) >= 0 &&
if (!span1.length) return;
!mw.config.get( 'wgMFMode' ) // WMF官方修复:移动端Minerva禁用,避免重复按钮
var span0 = span1.clone();
) {
$( function edittop_hookedittopHook() {
var localtitles = {
'en': 'Edit lead section',
'ja': '導入部を編集',
'zh': '编辑首段',
'zh-cn': '编辑首段',
'zh-hans': '编辑首段',
'zh-hant': '編輯首段'
};
 
var $content = $( '#mw_header h1content, #contentmw_content' h1').first().append(span0);
var $span1 = our_content$content.find( 'span.mw-editsection:not(.plainlinks)' ).first();
span0.find('a').each(function(idx) {
if ( !$span1.length ) return;{
var a = $(this);
return;
var href = a.attr('href') || '';
}
var $span0 = $span1.clone();
// WMF官方修复:移除CDX大按钮样式,适配Vector 2022
$span0.removeClass( 'cdx-button--size-large' );
 
$( '#mw_header h1, #content h1' ).first().append( $span0 );
// 获取用户语言,优先匹配精确键,再匹配 hans/hant 前缀,默认使用 hans
$span0.find( 'a' ).each( function (idx) {
var userLang = mw.config.get('wgUserLanguage');
var $a = $( this ), href;
var linkText = localtitles[userLang] ||
var userLang = mw.config.get( 'wgUserLanguage' );
(userLang.indexOf('hans') !== -1 ? localtitles.hans : '') ||
// 匹配对应语言文案,兜底英文
(userLang.indexOf('hant') !== -1 ? localtitles.hant : '') ||
var linkTexttextLabel = localtitles[ userLang ] || localtitles.en;
localtitles.hans; // 最终 fallback 到简体中文(hans)
 
// 悬浮提示 + 按钮显示文字
a.text(linkText);
$a.attr( 'title', linkTexttextLabel );
$a.text( textLabel );
 
var href = $a.attr( 'href' ) || '#';
if (!/&(ve|)section=T/.test(href)) {
// 上游原版分支逻辑完整保留
a.attr('href', href.replace(/&(ve|)section=\d+/, '&$1section=0&summary=/*%20top%20*/%20'));
} else if ( !/&vesection(ve|)section=T/.test( href ) ) { // 非嵌入页面
$a.attr( 'href', mwhref.util.getUrlreplace(mw.config.get /&('wgPageName've|)) section=\d+/, '?veaction=edit&vesection$1section=0&summary=/*%20top%20*/%20' ) );
} else if ( /&vesection=/.test( href ) ) { // 嵌入页面 - VE可视化编辑器
} else {
$a.attr( 'href', mw.util.getUrl( mw.config.get( 'wgPageName' ) ) + '?actionveaction=edit&sectionvesection=0&summary=/*%20top%20*/%20' );
} else { // 嵌入页面 - 传统编辑器
}
$a.attr( 'href', mw.util.getUrl( mw.config.get( 'wgPageName' ) ) + '?action=edit&section=0&summary=/*%20top%20*/%20' );
});
}
});
} );
} );
}