@@ -49,6 +49,42 @@ Can be used as follows in the declaration:
49
49
}
50
50
```
51
51
52
+ Example:
53
+
54
+ ``` js
55
+ export function convertTimeAgoToDate (document ) {
56
+ const timeElements = document .querySelectorAll (' time' );
57
+
58
+ timeElements .forEach (timeElement => {
59
+ const dateTimeValue = timeElement .getAttribute (' datetime' );
60
+ const textNode = document .createTextNode (dateTimeValue);
61
+ timeElement .parentNode .replaceChild (textNode, timeElement);
62
+ });
63
+ }
64
+ ```
65
+
66
+ ``` json
67
+ {
68
+ "name" : " MyService" ,
69
+ "terms" : {
70
+ "Privacy Policy" : {
71
+ "fetch" : " https://example.com/privacy" ,
72
+ "select" : " .content" ,
73
+ "filter" : [
74
+ " convertTimeAgoToDate"
75
+ ]
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ Result:
82
+
83
+ ``` diff
84
+ - <p class="meta-data">Last update: <time datetime="2025-06-23T11:16:36Z" title="06/23/2025, 13:16" data-datetime="relative">2 months ago</time></p>
85
+ + <p class="meta-data">Last update: 2025-06-23T11:16:36Z</p>
86
+ ```
87
+
52
88
### Filter with parameters
53
89
54
90
``` js
@@ -77,3 +113,50 @@ Can be used as follows in the declaration:
77
113
}
78
114
}
79
115
```
116
+
117
+ Example:
118
+
119
+ ``` js
120
+ export function removeLinksWithText (document , text ) {
121
+ const links = document .querySelectorAll (' a' );
122
+ links .forEach (link => {
123
+ if (link .textContent .trim () === text) {
124
+ link .remove ();
125
+ }
126
+ });
127
+ }
128
+ ```
129
+
130
+ ``` json
131
+ {
132
+ "name" : " MyService" ,
133
+ "terms" : {
134
+ "Privacy Policy" : {
135
+ "fetch" : " https://example.com/privacy" ,
136
+ "select" : " .content" ,
137
+ "filter" : [
138
+ { "removeLinksWithText" : " Return to previous section" }
139
+ { "removeLinksWithText" : " Go to next section" }
140
+ ]
141
+ }
142
+ }
143
+ }
144
+ ```
145
+
146
+ Result:
147
+
148
+ ``` diff
149
+ <div id="section1">
150
+ - <a href="#section2">Go to next section</a>
151
+ <p>...</p>
152
+ </div>
153
+ <div id="section2">
154
+ - <a href="#section1">Return to previous section</a>
155
+ - <a href="#section3">Go to next section</a>
156
+ <p>...</p>
157
+ </div>
158
+ <div id="section3">
159
+ - <a href="#section2">Return to previous section</a>
160
+ <p>...</p>
161
+ </div>
162
+ ```
0 commit comments