User:Bosco/Unsigned helper.js: Difference between revisions
From Test Wiki
Content deleted Content added
m Andrybak moved page User:Andrybak/sandbox/unsignedhelper.js to User:Andrybak/Scripts/Unsigned helper.js: publish from sandbox |
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; |
||
} |
} |
||
| ⚫ | |||
// get text without trailing whitespace |
// get text without trailing whitespace |
||
| ⚫ | |||
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); |
||
} |
} |
||