Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
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.
if(document.getElementsByClassName('editButtons')[0]!='undefined'){document.getElementsByClassName('editButtons')[0].innerHTML+='<input type="button" id="saveandedit_button" name="saveandedit_button" value="Save and edit" onclick="saveandedit_prompt()" />';}//function for returningfunctionsaveandedit_prompt(){//for displaying message on fail:form='<div id="saveandedit_status"></div>';jsMsg(form);varnewtext=document.editform.wpTextbox1.value;varsummary=document.editform.wpSummary.value;varnotminor=document.editform.wpMinoredit.checked;summary+=' (using [[User:mabdul/saveandedit.js|Save&Edit]])';//some advertising//get the tokenvarreq=sajax_init_object();req.open("GET",mw.config.get('wgScriptPath')+"/api.php?action=query&prop=info&indexpageids=1&intoken=edit&format=json&titles="+encodeURIComponent(mw.config.get('wgPageName')),false);req.send(null);varresponse=eval('('+req.responseText+')');pageid=response['query']['pageids'][0];token=response['query']['pages'][pageid]['edittoken'];deletereq;//Check if only a section will be editedvarurl=String(window.location);varsection="no";if(window.location.search!=""){varundef=url.split("?");varargs=undef[1].split("&");for(i=0;i<args.length;i++){vara=args[i].split("=");if(a[0]=='section')section=a[1];}}//do the editvarreq=sajax_init_object();varparams="action=edit";if(section!="no")params+="§ion="+section;params+="&format=json&token="+encodeURIComponent(token)+"&title="+encodeURIComponent(mw.config.get('wgPageName'))+"&text="+encodeURIComponent(newtext)+"¬minor="+notminor+"&summary="+encodeURIComponent(summary);url=mw.config.get('wgScriptPath')+"/api.php";req.open("POST",url,true);req.setRequestHeader("Content-type","application/x-www-form-urlencoded");req.setRequestHeader("Content-length",params.length);req.setRequestHeader("Connection","close");req.onreadystatechange=function(){if(req.readyState==4&&req.status==200){response=eval('('+req.responseText+')');try{if(response['edit']['result']=="Success"){//reload on the successwindow.location.reload();}else{//or handle out the error messagedocument.getElementById('saveandedit_status').innerHTML='<div style="color:red"><b>Edit failed on <a href="'+mw.config.get('wgArticlePath').replace("$1",encodeURI(mw.config.get('wgPageName')))+'" title="'+mw.config.get('wgPageName')+'">'+mw.config.get('wgPageName')+'</a></b></div>. Best try it again (<b>Don\'t forget to copy the text</b>). Error info:'+response['error']['code']+' : '+response['error']['info'];}}catch(err){document.getElementById('saveandedit_status').innerHTML='<div style="color:red"><b>Edit failed on <a href="'+mw.config.get('wgArticlePath').replace("$1",encodeURI(mw.config.get('wgPageName')))+'" title="'+mw.config.get('wgPageName')+'">'+mw.config.get('wgPageName')+'</a></b></div>';}deletereq;}};req.send(params);}