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.
// --------------------------------------- --------------------------------------- //// ----------------------------------- Credits ------------------------------------ ////// This script was created by modifying the following scripts:// [[User:Lightmouse/monobook.js/script.js]]// [[Wikipedia:WikiProject User scripts/Scripts/Formatter]]//// This script is intended to be complimentary to these scripts with very little// to no duplication of function.// ---------------------------------- Disclaimer ---------------------------------- ////// Use at your own risk and make sure you check the edit changes before you save//// Let me know [[User_Talk:Plastikspork]] if you find bugs!// ----------------------------- Installing the Script ---------------------------- ////// (1) Open/Create your USERNAME/monobook.js page, where USERNAME is your username.// A quick way to get there is to go to your user page, then append// '/monobook.js' to the end of the URL.//// (2) Put the following command on your monobook.js page:// importScript('User:Plastikspork/date.js');//// (3) Save the page and reload it by following the instructions at the top of your// monobook.js page. For example, Ctrl+Shift+R in Firefox.// ------------------------------- Using the Script ------------------------------- ////// (1) Open an article which you would like to edit, and you should see a bunch of// 'Spork' buttons in your 'toolbox' on the left side of your browser.//// (2) Click on one of the Spork buttons and the script will run, performing edits// by pattern matches. When it is finished, it will show you the changes and// add some comments to the edit summary. It is up to you to accept these// changes as is by clicking 'Save page', modify the changes by further editing// the edit form, or reject by leaving the page.//// Note: The script will run very slowly on very large pages, but it does always// eventually complete in my experience.// ----------------------------- Current Functionality ---------------------------- ////// [Sprk: cite date to mdy] Changes date = YYYY-MM-DD to date = Month DD, YYYY//// [Sprk: cite date to dmy] Changes date = YYYY-MM-DD to date = DD Month YYYY//// [UnSprk: cite date] Reverses prior two commands// Set Default Button Namesif(typeof(SporkConfig)=='undefined')SporkConfig={};if(typeof(SporkConfig.cmdy)=='undefined')SporkConfig.cmdy="Sprk: cite date mdy";if(typeof(SporkConfig.cdmy)=='undefined')SporkConfig.cdmy="Sprk: cite date dmy";if(typeof(SporkConfig.unc)=='undefined')SporkConfig.unc="UnSprk: cite date";// --------------------------------------- --------------------------------------- //// Import Spork-Tools scriptsimportScript('User:Plastikspork/datetools.js');// --------------------------------------- --------------------------------------- //// Spork: cite date mdyfunctionspork_cite_to_mdy(clk){vartxt=document.editform.wpTextbox1;txt.value=spork_yyyymmdd_to_mdy(txt.value);// See User:Plastikspork/datetools.jstxt.value=spork_dmy_to_mdy(txt.value);// See User:Plastikspork/datetools.jsspork_edit_summary_date();if(clk)document.editform.wpDiff.click();}// Spork: cite date dmyfunctionspork_cite_to_dmy(clk){vartxt=document.editform.wpTextbox1;txt.value=spork_yyyymmdd_to_dmy(txt.value);// See User:Plastikspork/datetools.jstxt.value=spork_mdy_to_dmy(txt.value);// See User:Plastikspork/datetools.jsspork_edit_summary_date();if(clk)document.editform.wpDiff.click();}// Unspork: cite datefunctionspork_cite_to_yyyymmdd(clk){vartxt=document.editform.wpTextbox1;txt.value=spork_mdy_to_yyyymmdd(txt.value);// See User:Plastikspork/datetools.jstxt.value=spork_dmy_to_yyyymmdd(txt.value);// See User:Plastikspork/datetools.jsspork_edit_summary_date();if(clk)document.editform.wpDiff.click();}// ----------------------------- interface Functions ----------------------------- //functionspork_edit_summary_date(){// Add a tag to the summary boxvarsummary="date formatting";vartxt=document.editform.wpSummary;varfullsummary="Script assisted "+summary;if(txt.value.indexOf(summary)==-1){if(txt.value.match(/Script assisted [A-Za-z]/)){txt.value=txt.value.replace(/Script assisted /,fullsummary+"/");}elseif(txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)){txt.value+=" | "+fullsummary;}else{txt.value+=fullsummary;}}}$(function(){if(document.forms.editform){if(SporkConfig.cmdy!="")mw.util.addPortletLink('p-tb','javascript:spork_cite_to_mdy(1)',SporkConfig.cmdy);if(SporkConfig.cdmy!="")mw.util.addPortletLink('p-tb','javascript:spork_cite_to_dmy(1)',SporkConfig.cdmy);if(SporkConfig.unc!="")mw.util.addPortletLink('p-tb','javascript:spork_cite_to_yyyymmdd(1)',SporkConfig.unc);}});// [[Category:Wikipedia scripts]]