I'm trying to make an extension that:
- pulls webpage content with content.js
- insert the content in a SQLite database that is persistently stored on the hard disk
I have realised that SafariWebExtensionHandler only lives in a tab. That means every time the extension wants to insert data to the database, it has to re-initiate a connection to the SQLite file.
I'm wondering if there's a way to improve this to the state where there is a background SQLite instance that I could connect to any time from the extension JavaScript context.
My thoughts:
- Run a background daemon on macOS that maintains the SQLite connection. The daemon serves as an WebSocket server. The extension JavaScript connects to it via WebSocket.
- Cons: a background process is required. The Safari API
browser.runtime.sendNativeMessagewas not used.
- Cons: a background process is required. The Safari API
I'm thinking there's definitely a API that I have missed that would be suitable for this scenario. I'm completely new to macOS development, so please eli5.