Fix bad date computation in auto-comment feature

Related feedback:
https://old.reddit.com/r/uBlockOrigin/comments/1bxz6oi/
This commit is contained in:
Raymond Hill 2024-04-09 12:15:03 -04:00
parent 846c6462c3
commit a5f6c35bb0
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 2 additions and 6 deletions

View File

@ -605,14 +605,10 @@ onBroadcast(msg => {
this.hiddenSettings.autoCommentFilterTemplate.indexOf('{{') !== -1
) {
const d = new Date();
// Date in YYYY-MM-DD format - https://stackoverflow.com/a/50130338
const ISO8601Date = new Date(d.getTime() +
(d.getTimezoneOffset()*60000)).toISOString().split('T')[0];
const url = new URL(options.docURL);
comment =
'! ' +
comment = '! ' +
this.hiddenSettings.autoCommentFilterTemplate
.replace('{{date}}', ISO8601Date)
.replace('{{date}}', d.toLocaleDateString(undefined, { dateStyle: 'medium' }))
.replace('{{time}}', d.toLocaleTimeString())
.replace('{{hostname}}', url.hostname)
.replace('{{origin}}', url.origin)