Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
/*Author : Svetlana Tkachenko svetlana@members.fsf.orgThis file is a part of addInstantSaveToCodeEditor.Licence: GPLv3+Version: 0.1Release date: 2018-02-26Description: adds an instant save button to CodeEditor*/// Check that CodeEditor is loadedmw.loader.using(['mediawiki.api','oojs-ui'],function(){if('.wikiEditor-ui'){varbutton=newOO.ui.ButtonWidget({label:'Instant Save'});// Instant save on clickbutton.$element.click(function(){// Update button textbutton.setLabel('Saving...');// Get text area contentsvartextbox=$('#wpTextbox1');varcontext=textbox&&textbox.data('wikiEditor-context');varcurrentText=context.$textarea.textSelection('getContents');// Save the page via AJAX edit apivarapi=newmw.Api();api.postWithToken("edit",{action:'edit',title:mw.config.get('wgPageName'),text:currentText,summary:$('#wpSummary').val()+' ([[User:Gryllida/js/addInstantSaveToCodeEditor.js|assisted]])'}).done(function(data){// Success; Update button textbutton.setLabel('Instant Save');});});$('#wpDiffWidget').after(button.$element);}});// text: $('#wpTextbox1').text()