![]() |
VOOZH | about |
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 key and click the Reload toolbar button.
For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// pads a time to 2 digits functionpadtime(time){ return(time+'').padStart(2,'0'); } $(function(){ 'use strict'; // only run when editing if(mw.user.options.get('usebetatoolbar')&& /edit|submit/.test(mw.config.get('wgAction'))){ // wait on the API library mw.loader.using('mediawiki.api').then(function(){ // fetch the username and timestamp of the last revision newmw.Api().get({ action:'query', titles:mw.config.get('wgPageName'), prop:'revisions', rvprop:'user|timestamp', formatversion:2 }).done(function(data){ varpage=data.query.pages[0]; // if the revision is missing, skip if(page.missing){ return; } // fetch data from the revision varrevision=page.revisions[0]; varuser=revision.user; vardate=newDate(revision.timestamp); // on the odd chance it fails to parse the date, skip date varinsert; if(isNaN(date.getTime())){ insert='{{subst:'+'unsigned|'+user+'}}'; }else{ // wish there was an easier way to do this, I miss moment.js vartimestamp=padtime(date.getUTCHours())+':'+padtime(date.getUTCMinutes())+', '+date.getUTCDate()+' '+date.toLocaleDateString('en-us',{month:'long',timeZone:'UTC'})+' '+date.getUTCFullYear(); insert='{{subst:'+'unsigned|'+user+'|'+timestamp+'}}'; } // add the editor button mw.loader.using('ext.wikiEditor').then(function(){ $('#wpTextbox1').wikiEditor('addToToolbar',{ section:'advanced', group:'insert', tools:{ autosign:{ label:'Autosign previous comment', type:'button', icon:'https://upload.wikimedia.org/wikipedia/commons/b/b3/Insert-signature.svg', action:{type:'replace',options:{pre:insert}} } } }); }); }); }); } });