Updated: 12.Feb.2024
MV3 doesn't support remote hosted code anymore so everything should be bind inside extension package.
Save Firebase Javascript modules inside /js/firebase/ of extension root.
E.g. files: https://www.gstatic.com/firebasejs/10.8.0/firebase-app.js
https://www.gstatic.com/firebasejs/10.8.0/firebase-firestore.js
E.g. for this case firebase-firestore.js at end of line #1 :
from 'https://www.gstatic.com/firebasejs/10.8.0/firebase-app.js'
to
from './firebase-app.js';
Then add firebase_config.js from below to the same folder /js/firebase.
Add inject.js inside root of package.
content-scripts.js
I use an event listener in
content-scripts.js
to send structured events tobackground.js
fromrandomwebsite.js
which is the script injected to www.randomwebsite.com. You can ignore 'keep-awake' events. I just used them to keep background script awake by sending non-functional events every 5 seconds.You can send an event in
randomwebsite.js
like:Finally, this is the
background.js
, where I handle every event sent here:Inversely, you can also get info from
background.js
and pass it to some script viacontent-scripts.js