Firebase in a chrome extension
Adding firebase/firestore to chrome extension
in chrome extension manifest file manifest.json add firebase-app.js (https://www.gstatic.com/firebasejs/7.5.0/firebase-app.js) and firebase-firestore.js(https://www.gstatic.com/firebasejs/7.5.0/firebase-firestore.js) as follows
1
...
2
"content_scripts": [
3
{
4
"matches": [
5
"https://www.wsj.com/*"
6
],
7
"js": [
8
"firebasejs/7.5.0/firebase-app.js",
9
"firebasejs/7.5.0/firebase-firestore.js",
10
...
Copied!
As well as
1
...
2
"content_security_policy":"script-src 'self' https://www.gstatic.com/ https://*.firebaseio.com https://www.googleapis.com; object-src 'self'"
3
}
Copied!
then in your extension code you can just initialise firebase as usual eg
1
const firebaseConfig = {
2
apiKey: "XXX",
3
authDomain: "XXX",
4
databaseURL: "XXX",
5
projectId: "XXX",
6
storageBucket: "XXX",
7
messagingSenderId: "XXX",
8
appId: "XXX",
9
measurementId: "XXX"
10
};
11
​
12
firebase.initializeApp(firebaseConfig);
13
const db = firebase.firestore();
14
​
15
// do something with firebase/firestore
Copied!
​
Last modified 1yr ago
Copy link