0
votes

I have put this in manifest:

"content_security_policy":"script-src 'self' https://www.gstatic.com/ https://*.firebaseio.com https://www.googleapis.com; object-src 'self'"

In popup.html:

 <script src="https://www.gstatic.com/firebasejs/3.9.0/firebase.js"></script>

But each time I firebase variable is not defined (console say that)

2

2 Answers

3
votes

You may refer with this related SO post. You encountered that error maybe because you are injecting the Firebase library by using document.body.append(...). Then, you're trying to access the Firebase library from inside your extension, but chrome extensions are sandboxed away from the web page. You injected the Firebase library into the web page, so it is not directly accessible to your extension. You may try to download the Firebase library JavaScript, and add the Firebase code to your chrome extension manifest.

It's also stated that there's an example chrome extension with Firebase in GitHub which you can use for reference: https://github.com/firebase/firebase-chrome-extension.

0
votes

you need to initialise firebase with your api config in javascript

var config = {
apiKey: "AIzaSyAqFmfmNWi95nt6TemvBMjPepulwV5WyZg",
authDomain: "define-web-ext.firebaseapp.com",
databaseURL: "https://define-web-ext.firebaseio.com",
projectId: "define-web-ext",
storageBucket: "",
messagingSenderId: "217235378805"
};
firebase.initializeApp(config);

if you are using npm packages , get firebase packages according to your framework .