Skip to content

Commit

Permalink
update tag on all trusteds and update about-trusteds
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-atr committed Nov 10, 2022
1 parent c252d85 commit 9354743
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/scriptlets/trusted-click-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {

/* eslint-disable max-len */
/**
* @scriptlet trusted-click-element
* @trustedscriptlet trusted-click-element
*
* @description
* Clicks selected elements in a strict sequence, ordered by selectors passed, and waiting for them to render in the DOM first.
Expand Down
2 changes: 1 addition & 1 deletion src/scriptlets/trusted-replace-xhr-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {

/* eslint-disable max-len */
/**
* @scriptlet trusted-replace-xhr-response
* @trustedscriptlet trusted-replace-xhr-response
*
* @description
* Replaces response content of `xhr` requests if **all** given parameters match.
Expand Down
2 changes: 1 addition & 1 deletion src/scriptlets/trusted-set-cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {

/* eslint-disable max-len */
/**
* @scriptlet trusted-set-cookie
* @trustedscriptlet trusted-set-cookie
*
* @description
* Sets a cookie with arbitrary name and value, with optional path
Expand Down
2 changes: 1 addition & 1 deletion src/scriptlets/trusted-set-local-storage-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {

/* eslint-disable max-len */
/**
* @scriptlet trusted-set-local-storage-item
* @trustedscriptlet trusted-set-local-storage-item
*
* @description
* Adds item with arbitrary key and value to localStorage object, or updates the value of the key if it already exists.
Expand Down
47 changes: 47 additions & 0 deletions wiki/about-trusted-scriptlets.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* [trusted-replace-fetch-response](#trusted-replace-fetch-response)
* [trusted-replace-xhr-response](#trusted-replace-xhr-response)
* [trusted-set-cookie](#trusted-set-cookie)
* [trusted-set-local-storage-item](#trusted-set-local-storage-item)
* * *
### <a id="trusted-click-element"></a> ⚡️ trusted-click-element

Expand Down Expand Up @@ -227,3 +228,49 @@ example.org#%#//scriptlet('trusted-set-cookie', 'cmpconsent', 'decline', '', '',
[Redirect source](../src/scriptlets/trusted-set-cookie.js)
* * *
### <a id="trusted-set-local-storage-item"></a> ⚡️ trusted-set-local-storage-item
Adds item with arbitrary key and value to localStorage object, or updates the value of the key if it already exists.
Scriptlet won't set item if storage is full.
**Syntax**
```
example.com#%#//scriptlet('trusted-set-local-storage-item', 'key', 'value')
```
- `key` — required, key name to be set.
- `value` - required, key value; possible values:
- arbitrary value
- `$now$` keyword for setting current time in ms, corresponds to `Date.now()` and `(new Date).getTime()` calls
- `$currentDate$` keyword for setting string representation of the current date and time, corresponds to `Date()` and `(new Date).toString()` calls
**Examples**
1. Set local storage item
```
example.org#%#//scriptlet('trusted-set-local-storage-item', 'player.live.current.mute', 'false')

example.org#%#//scriptlet('trusted-set-local-storage-item', 'COOKIE_CONSENTS', '{"preferences":3,"marketing":false}')

example.org#%#//scriptlet('trusted-set-local-storage-item', 'providers', '[16364,88364]')

example.org#%#//scriptlet('trusted-set-local-storage-item', 'providers', '{"providers":[16364,88364],"consent":"all"}')
```
2. Set item with current time since unix epoch in ms
```
example.org#%#//scriptlet('trusted-set-local-storage-item', 'player.live.current.play', '$now$')
```
3. Set item with current date, e.g 'Tue Nov 08 2022 13:53:19 GMT+0300'
```
example.org#%#//scriptlet('trusted-set-local-storage-item', 'player.live.current.play', '$currentDate$')
```
4. Set item without value
```
example.org#%#//scriptlet('trusted-set-local-storage-item', 'ppu_main_none', '')
```
[Redirect source](../src/scriptlets/trusted-set-local-storage-item.js)
* * *

0 comments on commit 9354743

Please sign in to comment.