User:Diegodlh/CitoidEDTF.js

/* Appends "-XX" at the end of YYYY-MM dates returned by Citoid. See T132308 mw.loader.using( 'ext.visualEditor.desktopArticleTarget.init', function {  mw.hook( 've.activationComplete' ).add( function  { // monkey-patch CitoidInspector's populateTemplate const populateTemplate = ve.ui.CitoidInspector.static.populateTemplate; ve.ui.CitoidInspector.static.populateTemplate = function(template, citation) { // all Citoid fields mapping to the "date" base field [       'date', 'dateDecided', 'filingDate', 'issueDate', 'dateEnacted' ].forEach((field) => {       const value = citation[field];        if ( value !== undefined && typeof value === 'string' && value.match(/^\d{4}-\d{2}$/) ) {         citation[field] = value + "-XX";        }      }); return populateTemplate.bind(this)(template, citation); }; }); });