User:Certes/unlink days.js

// This script unlinks days of the week. // Mostly copied from User:Ohconfucius/script/MOSNUM dates.js

// $.when(	$.ajax("//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js", { dataType: "script", cache: true }),	$.ajax("//en.wikipedia.org/w/index.php?title=User:Ohconfucius/script/MOSNUM_utils.js&action=raw&ctype=text/javascript", { dataType: "script", cache: true }) ).then(function {	pathoschild.TemplateScript.add( [			{				name: "Unlink days", tooltip: "Remove wikilinks from Sunday, etc.", script: unlink_days_driver }		],

// common options { forActions: "edit", category: "MOSNUM Dates" } ); });

/** **/ function unlink_days_driver(editor) { ohc_extend_editor(editor);

unlink_days(editor);

edit_summary(editor); }

/** * Add custom extension methods to the TemplateScript editor. * @param editor The TemplateScript editor to extend. */ function ohc_extend_editor(editor) { editor.ohc_regex = function(rg, sub, func) { var text = editor.get; text = ohc.dateutil.regex(text, rg, sub, func); editor.set(text);

return editor; }; }

function unlink_days(editor) { editor.replace(/\[\[ *((Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day) *\]\]/gi, "$1") // Monday → Monday, etc. }

/** **/ /// EDIT SUMMARIES & USE DMY TEMPLATE // this function modified 2019-03-27 from Special:Permalink/846525463 // format parameter must be 'dmy' or 'mdy'

function edit_summary(editor) { editor .options({ minor: true }) .appendEditSummary("Unlink days of week") .clickDiff; }

//