Jump to content

User:JJPMaster/superCoordInserterPref.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 EdgeandSafari:Hold down the⇧ Shiftkey and click theReloadtoolbar button. For details and instructions about other browsers, seeWikipedia:Bypass your cache.
mw.loader.load(`/w/index.php?title=User:${mw.config.get("wgUserName")}/SCIpref.js&action=raw&ctype=text/javascript`);
$(function(){
if(mw.config.get("wgPageName").toLowerCase()=="user:jjpmaster/supercoordinserter/preferences"){
document.title="SuperCoordInserter Preferences -"+mw.config.get("wgSiteName");
document.getElementById("firstHeading").innerText="SuperCoordInserter Preferences";
document.getElementById("bodyContent").innerHTML="<p>Loading...</p>"
setTimeout(()=>{
document.getElementById("bodyContent").innerHTML=`<p>Below, enter the amount of time (in seconds) that you want the script to wait before updating the page. <br/><b>Current:${myDelay}</b></p>
<form id= "SCIform" >
<label for= "fname" ></label><br>
<input type= "text" id= "delay" name= "delay" value= "${myDelay}"><br>
<input type= "submit" value= "Submit" >
</form>
`;
document.getElementById("SCIform").addEventListener("submit",(e)=>{
e.preventDefault();
vartime=document.getElementById("delay").value;
varparams={
action:'edit',
title:`User:${mw.config.get("wgUserName")}/SCIpref.js`,
text:`var myDelay =${time};`,
summary:'Set [[User:JJPMaster/superCoordInserter]] preferences',
format:'json'
},
api=newmw.Api();

api.postWithToken('csrf',params).done(function(data){
console.log(data);
});
});
},2000);
}
});