Skip to content

Commit

Permalink
Improve trusted-set-local-storage-item scriptlet
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed May 5, 2024
1 parent f0cfc77 commit 2ccc313
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -1052,12 +1052,14 @@ function setLocalStorageItemFn(
];

if ( trusted ) {
if ( value === '$now$' ) {
value = Date.now();
} else if ( value === '$currentDate$' ) {
value = `${Date()}`;
} else if ( value === '$currentISODate$' ) {
value = (new Date()).toISOString();
if ( value.includes('$now$') ) {
value.replaceAll('$now$', Date.now());
}
if ( value.includes('$currentDate$') ) {
value.replaceAll('$currentDate$', `${Date()}`);
}
if ( value.includes('$currentISODate$') ) {
value.replaceAll('$currentISODate$', (new Date()).toISOString());
}
} else {
const normalized = value.toLowerCase();
Expand Down

0 comments on commit 2ccc313

Please sign in to comment.