13
13
- [ trusted-set-cookie-reload] ( #trusted-set-cookie-reload )
14
14
- [ trusted-set-cookie] ( #trusted-set-cookie )
15
15
- [ trusted-set-local-storage-item] ( #trusted-set-local-storage-item )
16
+ - [ trusted-set-session-storage-item] ( #trusted-set-session-storage-item )
16
17
- [ trusted-suppress-native-method] ( #trusted-suppress-native-method )
17
18
18
19
* * *
@@ -130,10 +131,14 @@ Creates an element with specified attributes and text content, and appends it to
130
131
131
132
### Syntax
132
133
134
+ <!-- markdownlint-disable line-length -->
135
+
133
136
``` text
134
- example.com#%#//scriptlet('trusted-create-element', parentSelector, tagName[, attributePairs[, textContent[, cleanupDelayMs]]]) <!-- markdownlint-disable-line line-length -->
137
+ example.com#%#//scriptlet('trusted-create-element', parentSelector, tagName[, attributePairs[, textContent[, cleanupDelayMs]]])
135
138
```
136
139
140
+ <!-- markdownlint-enable line-length -->
141
+
137
142
- ` parentSelector ` — required, CSS selector of the parent element to append the created element to.
138
143
- ` tagName ` — required, tag name of the created element.
139
144
- ` attributePairs ` — optional, space-separated list of attribute name and value pairs separated by ` = ` .
@@ -160,10 +165,14 @@ example.com#%#//scriptlet('trusted-create-element', parentSelector, tagName[, at
160
165
161
166
1. Create a button element with multiple attributes, including attribute without value, and text content
162
167
168
+ <!-- markdownlint-disable line-length -->
169
+
163
170
```adblock
164
- example.com#%#//scriptlet('trusted-create-element', 'body', 'button', 'disabled aria-hidden="true" style="width: 0px"', 'Press here') <!-- markdownlint-disable-line line-length -->
171
+ example.com#%#//scriptlet('trusted-create-element', 'body', 'button', 'disabled aria-hidden="true" style="width: 0px"', 'Press here')
165
172
```
166
173
174
+ <!-- markdownlint-enable line-length -->
175
+
167
176
1. Create a button element with an attribute whose value contains quotes
168
177
169
178
```adblock
@@ -173,7 +182,7 @@ example.com#%#//scriptlet('trusted-create-element', parentSelector, tagName[, at
173
182
1. Create a paragraph element with text content and remove it after 5 seconds
174
183
175
184
```adblock
176
- example.com#%#//scriptlet('trusted-create-element', '.container > article', 'p', '', 'Hello world!', 5000)
185
+ example.com#%#//scriptlet('trusted-create-element', '.container > article', 'p', '', 'Hello world!', ' 5000' )
177
186
```
178
187
179
188
[Scriptlet source](../src/scriptlets/trusted-create-element.ts)
@@ -398,14 +407,14 @@ Replaces text in text content of matched DOM nodes.
398
407
399
408
### Syntax
400
409
401
- ```adblock
410
+ ```text
402
411
example.org#%#//scriptlet('trusted-replace-node-text', nodeName, textMatch, pattern, replacement)
403
412
```
404
413
405
414
- ` nodeName ` — required, string or RegExp, specifies DOM node name from which the text will be removed.
406
415
Must target lowercased node names, e.g ` div ` instead of ` DIV ` .
407
416
- ` textMatch ` — required, string or RegExp to match against node's text content.
408
- If matched, the whole text will be removed . Case sensitive.
417
+ If matched, the ` pattern ` will be replaced by the ` replacement ` . Case sensitive.
409
418
- ` pattern ` — required, string or regexp for matching contents of ` node.textContent ` that should be replaced.
410
419
- ` replacement ` — required, string to replace text content matched by ` pattern ` .
411
420
- ` ...extraArgs ` — optional, string, if includes 'verbose' will log original and modified text content.
@@ -541,7 +550,7 @@ example.org#%#//scriptlet('trusted-replace-outbound-text', methodPath[, textToRe
541
550
1. Call with `decodeMethod` and `logContent` arguments will log original and decoded text content of the specified function:
542
551
543
552
```adblock
544
- example.org#%#//scriptlet('trusted-replace-outbound-text', 'Array.prototype.join', '', '', 'base64' , '', 'true')
553
+ example.org#%#//scriptlet('trusted-replace-outbound-text', 'Array.prototype.join', '', '', 'base64', '', 'true')
545
554
```
546
555
547
556
1. Call with only first argument will log text content of the specified function:
@@ -621,10 +630,14 @@ example.org#%#//scriptlet('trusted-replace-xhr-response'[, pattern, replacement[
621
630
622
631
1. Replace text content of XMLHttpRequests matching by URL regex and request methods
623
632
633
+ <!-- markdownlint-disable line-length -->
634
+
624
635
```adblock
625
- example.org#%#//scriptlet('trusted-replace-xhr-response', '/#EXT-X-VMAP-AD-BREAK[\s\S]*?/', '#EXT-X-ENDLIST', '/\.m3u8/ method:/GET|HEAD/') <!-- markdownlint-disable-line line-length -->
636
+ example.org#%#//scriptlet('trusted-replace-xhr-response', '/#EXT-X-VMAP-AD-BREAK[\s\S]*?/', '#EXT-X-ENDLIST', '/\.m3u8/ method:/GET|HEAD/')
626
637
```
627
638
639
+ <!-- markdownlint-enable line-length -->
640
+
628
641
1. Remove all text content of all XMLHttpRequests for example.com
629
642
630
643
```adblock
@@ -813,6 +826,8 @@ example.org#%#//scriptlet('trusted-set-cookie-reload', name, value[, offsetExpir
813
826
- empty string for no value
814
827
- ` $now$ ` keyword for setting current time in ms, e.g 1667915146503
815
828
- ` $currentDate$ ` keyword for setting current time as string, e.g 'Tue Nov 08 2022 13:53:19 GMT+0300'
829
+ - ` $currentISODate$ ` keyword for setting current date in the date time string format,
830
+ e.g '2022-11-08T13:53:19.650Z'
816
831
- ` offsetExpiresSec ` — optional, offset from current time in seconds, after which cookie should expire;
817
832
defaults to no offset. Possible values:
818
833
- positive integer in seconds
@@ -890,6 +905,8 @@ example.org#%#//scriptlet('trusted-set-cookie', name, value[, offsetExpiresSec[,
890
905
- empty string for no value
891
906
- ` $now$ ` keyword for setting current time in ms, e.g 1667915146503
892
907
- ` $currentDate$ ` keyword for setting current time as string, e.g 'Tue Nov 08 2022 13:53:19 GMT+0300'
908
+ - ` $currentISODate$ ` keyword for setting current date in the date time string format,
909
+ e.g '2022-11-08T13:53:19.650Z'
893
910
- ` offsetExpiresSec ` — optional, offset from current time in seconds, after which cookie should expire;
894
911
defaults to no offset. Possible values:
895
912
- positive integer in seconds
@@ -966,6 +983,8 @@ example.com#%#//scriptlet('trusted-set-local-storage-item', 'key', 'value')
966
983
- ` $now$ ` keyword for setting current time in ms, corresponds to ` Date.now() ` and ` (new Date).getTime() ` calls
967
984
- ` $currentDate$ ` keyword for setting string representation of the current date and time,
968
985
corresponds to ` Date() ` and ` (new Date).toString() ` calls
986
+ - ` $currentISODate$ ` keyword for setting current date in the date time string format,
987
+ corresponds to ` (new Date).toISOString() ` call, e.g '2022-11-08T13:53:19.650Z'
969
988
970
989
### Examples
971
990
@@ -1003,6 +1022,68 @@ example.com#%#//scriptlet('trusted-set-local-storage-item', 'key', 'value')
1003
1022
1004
1023
* * *
1005
1024
1025
+ ## <a id="trusted-set-session-storage-item"></a> ⚡️ trusted-set-session-storage-item
1026
+
1027
+ > Added in v1.11.16.
1028
+
1029
+ Adds item with arbitrary key and value to sessionStorage object, or updates the value of the key if it already exists.
1030
+ Scriptlet won't set item if storage is full.
1031
+
1032
+ ### Syntax
1033
+
1034
+ ```adblock
1035
+ example.com#%#//scriptlet('trusted-set-session-storage-item', 'key', 'value')
1036
+ ```
1037
+
1038
+ - ` key ` — required, key name to be set.
1039
+ - ` value ` — required, key value; possible values:
1040
+ - arbitrary value
1041
+ - ` $now$ ` keyword for setting current time in ms, corresponds to ` Date.now() ` and ` (new Date).getTime() ` calls
1042
+ - ` $currentDate$ ` keyword for setting string representation of the current date and time,
1043
+ corresponds to ` Date() ` and ` (new Date).toString() ` calls
1044
+ - ` $currentISODate$ ` keyword for setting current date in the date time string format,
1045
+ corresponds to ` (new Date).toISOString() ` call, e.g '2022-11-08T13:53:19.650Z'
1046
+
1047
+ ### Examples
1048
+
1049
+ 1 . Set session storage item
1050
+
1051
+ <!-- markdownlint-disable line-length -->
1052
+
1053
+ ``` adblock
1054
+ example.org#%#//scriptlet('trusted-set-session-storage-item', 'player.live.current.mute', 'false')
1055
+
1056
+ example.org#%#//scriptlet('trusted-set-session-storage-item', 'COOKIE_CONSENTS', '{"preferences":3,"flag":false}')
1057
+
1058
+ example.org#%#//scriptlet('trusted-set-session-storage-item', 'providers', '[16364,88364]')
1059
+
1060
+ example.org#%#//scriptlet('trusted-set-session-storage-item', 'providers', '{"providers":[123,456],"consent":"all"}')
1061
+ ```
1062
+
1063
+ <!-- markdownlint-enable line-length -->
1064
+
1065
+ 1. Set item with current time since unix epoch in ms
1066
+
1067
+ ```adblock
1068
+ example.org#%#//scriptlet('trusted-set-session-storage-item', 'player.live.current.play', '$now$')
1069
+ ```
1070
+
1071
+ 1. Set item with current date, e.g 'Tue Nov 08 2022 13:53:19 GMT+0300'
1072
+
1073
+ ```adblock
1074
+ example.org#%#//scriptlet('trusted-set-session-storage-item', 'player.live.current.play', '$currentDate$')
1075
+ ```
1076
+
1077
+ 1. Set item without value
1078
+
1079
+ ```adblock
1080
+ example.org#%#//scriptlet('trusted-set-session-storage-item', 'ppu_main_none', '')
1081
+ ```
1082
+
1083
+ [Scriptlet source](../src/scriptlets/trusted-set-session-storage-item.ts)
1084
+
1085
+ * * *
1086
+
1006
1087
## <a id="trusted-suppress-native-method"></a> ⚡️ trusted-suppress-native-method
1007
1088
1008
1089
> Added in v1.10.25.
0 commit comments