User:Erutuon/scripts/editTop.js

// From w:MediaWiki:Gadget-edittop.js, with some modifications

var namespaceNumber = mw.config.get( "wgNamespaceNumber" ); var pageName = mw.config.get( "wgPageName" );

if ( [ "view", "purge" ].indexOf( mw.config.get( "wgAction" ) ) !== -1	&& [ 0, 1, 2, 3, 4, 5, 10, 100 ].indexOf( mw.config.get( "wgNamespaceNumber" ) ) !== -1 ) { $(function edittop_hook {		var localtitles = {			en: "Edit lead section",		};		var our_content = $("#content, #mw_content").first;		var span1 = our_content			.find("span.mw-editsection:not(.plainlinks):not(.anchor-gadget-link)")			.first;		if (!span1.length) {			return;		}		var span0 = span1.clone.prop("contenteditable", "false");		$("#mw_header h1, #content h1").first.append(span0);		span0.find("a").each(function (idx) { var a = $(this); a.attr("title", localtitles.en); var href = a.attr( "href" ); if (!href) return; a.attr("href",				// not transcluded				!/&(ve|)section=T/.test( href ) ? href.replace( /&(ve|)section=\d+/, "&$1section=0&summary=/*%20top%20*/%20" )				// transcluded, VE				: /&vesection=/.test( href ) ? mw.util.getUrl( pageName, { veaction: "edit", vesection: 0, summary: "/* top */ " } )				: mw.util.getUrl( pageName, { action: "edit", section: "0", summary: "/* top */ " } ) ); });	}); }