User:Bosco/Unsigned helper.js: Difference between revisions

From Test Wiki
Content deleted Content added
add advertisement to the edit summary
Line 356: Line 356:
const formattedTimestamp = `${h}:${m}, ${ts.getUTCDate()} ${months[ts.getUTCMonth()]} ${ts.getUTCFullYear()} (UTC)`;
const formattedTimestamp = `${h}:${m}, ${ts.getUTCDate()} ${months[ts.getUTCMonth()]} ${ts.getUTCFullYear()} (UTC)`;
return '{{subst:' + template + '|' + user + '|' + formattedTimestamp + '}}';
return '{{subst:' + template + '|' + user + '|' + formattedTimestamp + '}}';
}

function constructAd() {
return " (using [[w:User:Andrybak/Scripts/Unsigned helper|Unsigned helper]])";
}
}


Line 364: Line 368:
return;
return;
}
}
const oldText = editSummaryField.val().trimEnd();
// get text without trailing whitespace
// get text without trailing whitespace
let oldText = editSummaryField.val().trimEnd();
const ad = constructAd();
if (oldText.includes(ad)) {
oldText = oldText.replace(ad, '');
}
let newText = "";
let newText = "";
if (oldText.match(/[*]\/$/)) {
if (oldText.match(/[*]\/$/)) {
Line 375: Line 383:
newText = newSummary;
newText = newSummary;
}
}
editSummaryField.val(newText);
editSummaryField.val(newText + ad);
}
}