User:Atundo/prova2.js

(function {  var editButtons = document.getElementsByClassName('editButtons')[0];

if (!editButtons || !document.editform) { return; }

var conf = mw.config.get(['wgPageName']);

$(' ')   .val('SalvaEDioCan') .on('click', function {      saveandedit_prompt;    }) .appendTo(editButtons); console.warn("DIOCANE"); // Function for returning function saveandedit_prompt { mw.loader.using(['mediawiki.util', 'mediawiki.api.edit', 'mediawiki.notify'], function {      var section = mw.util.getParamValue('section');      var summary = document.editform.wpSummary.value;      // Some advertising      summary += ' (using Save&Edit)';

var params = { action: 'edit', title: conf.wgPageName, text: document.editform.wpTextbox1.value, summary: summary };     if (document.editform.wpMinoredit.checked) { params.notminor = '1'; }     // Check if only a section will be edited if (section) { params.section = section; }

var api = new mw.Api; api.postWithEditToken(params).done(function (response) {       if (response.edit.result === 'Success') {          // Reload on the success          location.reload;        } else {          // Handle out the error message          var error = $.parseHTML( ' Edit failed on ' + mw.html.element('a', { href: mw.util.getUrl(conf.wgPageName), title: conf.wgPageName }, conf.wgPageName ) + ' Best try it again (Don\'t forget to copy the text!). Error info: ' + (response.error && mw.html.escape(response.error.code + ' : ' + response.error.info)) + ' ' );         mw.notify(error, { autoHide: false });        }      }); }); } });