Skip to content

Commit 2b3ef7b

Browse files
committed
doc: simplify CSP info for GM_addElement
1 parent b3c1401 commit 2b3ef7b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

content/api/gm.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ Note: when setting this URL as `src` or `href` of a DOM element, it may fail on
211211

212212
*Since VM2.13.1*
213213

214-
Appends and returns an element with the specified attributes.
214+
Appends and returns an element with the specified attributes with the primary purpose of circumventing a strict `Content-Security-Policy` that forbids adding inline code or style.
215215

216216
```js
217217
let element1 = GM_addElement(tagName, attributes);
@@ -231,7 +231,7 @@ let element2 = GM_addElement(parentNode, tagName, attributes);
231231

232232
* <Field name="tagName" type="string" />
233233

234-
A tag name like `'script'`. Any valid HTML tag can be used, but the only motivation for this API was to add `script`, `link`, `style` elements when they are disallowed by a strict `Content-Security-Policy` of the site e.g. github.com, twitter.com.
234+
A tag name like `'script'`.
235235

236236
* <Field name="attributes?" type="object" />
237237

@@ -254,7 +254,6 @@ let el = GM_addElement(parentElement.shadowRoot, 'iframe', { src: url });
254254
Notes:
255255
* The element is returned immediately (synchronously) even with `GM.addElement`, no need for `.then()`, but you can use it if you want, just once though as it's auto-removed to avoid recursion. The API is synchronous because Violentmonkey runs scripts only when the root element appears, so there's always a node to serve as a parent.
256256
* Invalid arguments will raise an exception, which can be caught using `try {} catch (e) {}`, just like standard DOM API `document.createElement`.
257-
* This API is experimental in Tampermonkey, and hence subject to change.
258257

259258
### GM_addStyle
260259

0 commit comments

Comments
 (0)