mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-03 21:25:13 +00:00
[PR #559] Add WebContents insertCSS functionality #1211
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/ElectronNET/Electron.NET/pull/559
State: closed
Merged: Yes
Electron has functionality to insert CSS into a webpage using webContents.insertCSS. This PR implements that functionality in Electron.NET.
In
WebContents.cs, the methodpublic void InsertCSS(bool isBrowserWindow, string path)is added, which emits a socket message,webContents-insertCSS, along with theWebContentsID, the path to the file to insert, and whether the WebContents belongs to aBrowserWindow(isBrowserWindow=true) or to aBrowserView(isBrowserWindow=false).In
webContents.ts, the message is received and locates theBrowserWindoworBrowserViewthat matches the ID (sinceBrowserViews'WebContentsIDs 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 theBrowserWindoworBrowserView'sWebContents.