Jump to content

User:Fred Gandt/addCloneClearButtonAboveScributoConsole.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
$( document ).ready( () => {
	"use strict";
	if ( mw.config.get( "wgAction" ) === "edit" ) {
		const SCRIBUNTO_CONSOLE = document.getElementById( "mw-scribunto-console" );
		if ( SCRIBUNTO_CONSOLE ) {
			const CLEAR_BUTTON = SCRIBUNTO_CONSOLE.querySelector( 'input[type="button"][value="clear"i]' );
			if ( CLEAR_BUTTON ) {
				const CLEAR_BUTTON_CLONE = CLEAR_BUTTON.cloneNode();
				CLEAR_BUTTON_CLONE.addEventListener( "click", () => CLEAR_BUTTON.click(), { passive: true } );
				SCRIBUNTO_CONSOLE.prepend( CLEAR_BUTTON_CLONE );
			}
		}
	}
} );