User:Novem Linguae/Scripts/CWWEditSummary.js

//

// Adds a "Provide attribution" link to "Edit source" and "Speical:Import" pages. When clicked, provides the attribution text suggested at WP:CWW (Copying Within Wikipedia), which should satisfy CC BY-SA 3.0 legal requirements.

// Particularly useful on testwiki. Mildly useful on enwiki.

// See also User:Chlod/Scripts/Deputy/AttributionNoticeTemplateEditor

$( async function {	const action = mw.config.get( 'wgAction' );	let title = mw.config.get( 'wgPageName' ).replace( /_/g, ' ' );	const wiki = mw.config.get( 'wgDBname' );	const editSummaryAppend = '(CWWEditSummary)';	if ( action === 'edit' ) {		$( '.editCheckboxes > .oo-ui-layout' ).append( ' Provide attribution ' );

$( '#CWWEditSummary-Edit' ).on( 'click', function {			if ( wiki !== 'enwiki' ) {				title = 'w:' + title;			}			$( '#wpSummary' ).val( `Copied content from ${ title }; see that page's history for attribution ${ editSummaryAppend }` );		} ); } else if ( title === 'Special:Import' ) { $( '#mw-input-wpintro' ).parent( 3 ).after( ' Select defaults and provide attribution ' );

$( '#CWWEditSummary-SpecialImport' ).on( 'click', function {			$( '[name="interwiki"]' ).val( 'en' );			$( '[name="interwiki"] + .oo-ui-dropdownWidget > span > .oo-ui-labelElement-label' ).html( 'en' );			$( '[name="interwikiTemplates"]' ).prop( 'checked', true );			$( '[name="log-comment"]' ).val( `Copied content from another wiki; see the linked page's history for attribution ${ editSummaryAppend }` );			$( '[name="frompage"]' ).trigger( 'focus' );		} ); } } );

//