Skip to content

Conversation

@nfichter
Copy link

Electron has functionality to insert CSS into a webpage using webContents.insertCSS. This PR implements that functionality in Electron.NET.

In WebContents.cs, the method public void InsertCSS(bool isBrowserWindow, string path) is added, which emits a socket message, webContents-insertCSS, along with the WebContents ID, the path to the file to insert, and whether the WebContents belongs to a BrowserWindow (isBrowserWindow = true) or to a BrowserView (isBrowserWindow = false).

In webContents.ts, the message is received and locates the BrowserWindow or BrowserView that matches the ID (since BrowserViews' WebContents IDs are incremented by 1000 on the Electron.NET side but not on the Host side, the comparison here is done against the Host IDs + 1000), and calls the insertCSS on the BrowserWindow or BrowserView's WebContents.

@GregorBiswanger GregorBiswanger self-assigned this Jul 1, 2021
@GregorBiswanger GregorBiswanger added this to the 13.5.1 milestone Jul 1, 2021
@GregorBiswanger GregorBiswanger merged commit 9f78098 into ElectronNET:master Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants