The Problem
I'm writing a chrome extension that users will use to fill forms using content hosted in a firestore database. The core problem I'm facing is that Chrome Extension's Manifest Version 3 does not appear to support any of google's mechanisms for interacting with firestore.
Previously, with Manifest Version 2, you'd link to the CDN hosted firebase scripts in your background.html file like so:
<script src="https://www.gstatic.com/firebasejs/7.14.6/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.14.6/firebase-firestore.js"></script>
With MV3, remotely hosted code is no longer allowed for security reasons, despite the fact that the script I'm trying to link to is google's, and attempting to do so throws errors as soon as you load the unpacked extension.
My question:
How can I connect a Manifest Version 3 Chrome Extension to a firestore database?
What I've tried
I spent quite a lot of time experimenting with pulling the cdn scripts locally and then importing them directly into my background.js like so:
try {
importScripts('firebase/firebase-firestore.js');
} catch (error) {
console.log(error);
}
This approach led me deep down a rabbit hole because this also did not work but apparently for different reasons. Specifically, with MV3, XMLHttpRequest is not supported in a service worker.
Possible next steps
From the reading I've done, and I really hope somebody here can point me to something I've missed, it appears that it will not be possible to connect firestore to an extension directly. I have read elsewhere that the firebase realtime data base can be accessed via a MV3 chrome extension.
Setting up some link between firestore and the realtime database for the relevant content our users need to be able to access with the chrome extension and then connecting the realtime database to the extension seems like it is the next step. Is this viable?
Why not use Manifest Version 2?
Simply to future proof our app, we don't want to be left scrambling when MV2 is deprecated. While no deprecation date for MV2 appears on any official channel, the chromium blog says:
"While there is not an exact date for removing support for Manifest V2 extensions, developers can expect the migration period to last at least a year from when Manifest V3 lands in the stable channel."
Which puts MV2's end of life sometime early in 2022.
Edit to add:
They announced some hard dates, January 2022 they stop accepting new MV2 extensions but maintenance of those already existing may continue until January 2023 when all extensions must be MV3.
