feat: add removeInsertedCSS (#16579)
This commit is contained in:
parent
deebde66f9
commit
5a08522b98
8 changed files with 88 additions and 9 deletions
|
@ -987,9 +987,12 @@ Returns `String` - The user agent for this web page.
|
|||
|
||||
* `css` String
|
||||
|
||||
Returns `Promise<void>`
|
||||
Returns `Promise<String>` - A promise that resolves with a key for the inserted
|
||||
CSS that can later be used to remove the CSS via
|
||||
`contents.removeInsertedCSS(key)`.
|
||||
|
||||
Injects CSS into the current web page.
|
||||
Injects CSS into the current web page and returns a unique key for the inserted
|
||||
stylesheet.
|
||||
|
||||
```js
|
||||
contents.on('did-finish-load', function () {
|
||||
|
@ -997,6 +1000,22 @@ contents.on('did-finish-load', function () {
|
|||
})
|
||||
```
|
||||
|
||||
#### `contents.removeInsertedCSS(key)`
|
||||
|
||||
* `key` String
|
||||
|
||||
Returns `Promise<void>` - Resolves if the removal was successful.
|
||||
|
||||
Removes the inserted CSS from the current web page. The stylesheet is identified
|
||||
by its key, which is returned from `contents.insertCSS(css)`.
|
||||
|
||||
```js
|
||||
contents.on('did-finish-load', async function () {
|
||||
const key = await contents.insertCSS('html, body { background-color: #f00; }')
|
||||
contents.removeInsertedCSS(key)
|
||||
})
|
||||
```
|
||||
|
||||
#### `contents.executeJavaScript(code[, userGesture])`
|
||||
|
||||
* `code` String
|
||||
|
|
|
@ -99,7 +99,18 @@ webFrame.setSpellCheckProvider('en-US', {
|
|||
|
||||
* `css` String - CSS source code.
|
||||
|
||||
Inserts `css` as a style sheet in the document.
|
||||
Returns `String` - A key for the inserted CSS that can later be used to remove
|
||||
the CSS via `webFrame.removeInsertedCSS(key)`.
|
||||
|
||||
Injects CSS into the current web page and returns a unique key for the inserted
|
||||
stylesheet.
|
||||
|
||||
### `webFrame.removeInsertedCSS(key)`
|
||||
|
||||
* `key` String
|
||||
|
||||
Removes the inserted CSS from the current web page. The stylesheet is identified
|
||||
by its key, which is returned from `webFrame.insertCSS(css)`.
|
||||
|
||||
### `webFrame.insertText(text)`
|
||||
|
||||
|
|
|
@ -379,9 +379,21 @@ Returns `String` - The user agent for guest page.
|
|||
|
||||
* `css` String
|
||||
|
||||
Returns `Promise<void>`
|
||||
Returns `Promise<String>` - A promise that resolves with a key for the inserted
|
||||
CSS that can later be used to remove the CSS via
|
||||
`<webview>.removeInsertedCSS(key)`.
|
||||
|
||||
Injects CSS into the guest page.
|
||||
Injects CSS into the current web page and returns a unique key for the inserted
|
||||
stylesheet.
|
||||
|
||||
### `<webview>.removeInsertedCSS(key)`
|
||||
|
||||
* `key` String
|
||||
|
||||
Returns `Promise<void>` - Resolves if the removal was successful.
|
||||
|
||||
Removes the inserted CSS from the current web page. The stylesheet is identified
|
||||
by its key, which is returned from `<webview>.insertCSS(css)`.
|
||||
|
||||
### `<webview>.executeJavaScript(code[, userGesture])`
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue