Best architecture for headless browser in plugin?

I’m working on a plugin that needs to be able to run a full browser in the background (complete with cookies and local storage).

My first attempt was using puppeteer, but I ran into a problem because puppeteer can’t run in a browser… That’s when it occurred to me that Obsidian is technically running in a browser already.

So I have some options:
Option A) Spawn a node.js process to handle the puppeteer stuff
Option B) hook into the browser apis of obsidian’s electron host

Are there better options? And for either option above, how might I do that?