Uncaught ReferenceError: база данных не определена - расширение Google Chrome, Background.js - PullRequest
0 голосов
/ 29 октября 2019

Я пытаюсь читать / записывать данные в базу данных Firebase, но не могу правильно импортировать Firebase в свое расширение Google Chrome. Вся помощь приветствуется.

Я пытаюсь импортировать его в popup.html

<!DOCTYPE html>
<html>
  <head>
    <style>
      button {
        height: 30px;
        width: 30px;
        outline: none;
      }
    </style>
  </head>
  <body>
    <button id="startButton"></button>
    <button id="stopButton"></button>
    <script src="https://www.gstatic.com/firebasejs/7.2.2/firebase.js"></script>
    <script src="popup.js"></script>


</body>
</html>

Затем я вызываю его в background.js, где я получаю ошибку: Uncaught ReferenceError: firebase is not defined

var config = {
  apiKey: "xxxx",
  databaseURL: "xxxx",
  storageBucket: "xxx"
};

firebase.initializeApp(config); //Error
...

и я установил свои правила в manifest.json

{
    "name": "Company Websites",
    "version": "1.0",
    "description": "Build an Extension!",
    "background": {
        "scripts": ["background.js"],
        "persistent": false
      },
      "content_scripts": [
        {
          "matches": ["<all_urls>","http://*/*", "https://*/*"],
          "js": ["scrapeSearch.js"]
        }
      ],
      "page_action": {
        "default_popup": "popup.html"
      },
      "content_security_policy": "script-src 'self' https://www.gstatic.com/ https://*.firebaseio.com https://www.googleapis.com; object-src 'self'; connect-src 'self' wss://*.firebaseio.com;",
      "permissions": ["tabs","storage","declarativeContent", "activeTab"],
    "manifest_version": 2
  }

Заранее спасибо,

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...