Electron availability #6
WimTibackx
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I came across this repository when wanting to port a selenium-based script I had lying around to an obsidian plugin. I did some further investigation of my own, but it seemed to be that importing selenium to an obsidian plugin would be difficult/impossible because of it's reliance on
node:events
and dynamic imports.Afterwards, I wondering whether it was possible to access the internal electron in Obsidian. Turns out it is! Can be tested via devtools by accessing the
electron
global variable. To use the full swathe of electron APIs, you may need to accesselectron.remote
.For example, the electron repo has this example for rendering an url on an offscreen webview and grabbing a screenshot of it. While I didn't try the screenshot myself (as it uses
node:fs
) I can run that code sample by adjustingelectron
toelectron.remote
. As a rough demo, dumping the following code in obsidian devtools console opens a hidden window, loads github.com, executes some javascript on that page and returns the result of that to you. Optionally, you can open devtools and avoid closinfg the window to verify results.I've further tried wrapping that idea into cleaner promises and into an obsidian plugin and can confirm it actually works from the plugin-system. Figured that might be useful info for the creator and anyone coming across this repo.
Have a nice day!
Wim
Beta Was this translation helpful? Give feedback.
All reactions