Code Monkey home page Code Monkey logo

chrome-extension-boilerplate's Introduction

Chrome Extension Boilerplate with Manifest V3 and Firebase 9

This boilerplate provides a quick and easy way to create a Chrome extension using Manifest V3 and Firebase 9. This is particularly useful since Manifest V3 does not allow you to import Firebase using a CDN. Instead, you will use local Firebase files and interact with them through the background.js using event listeners.

Example Usage

  1. Set up your Firebase project and get your configuration keys.
  2. Replace the placeholders [ENTER-YOUR-KEYS] in the firebaseConfig object inside background.js with your actual Firebase configuration keys.
  3. Modify the COLLECTION-NAME in background.js to match the desired Firestore collection name.
  4. Update the matches property in the manifest.json file to match the target website(s) where your extension will be active.

Fetch data from Firestore

async function fetchData() {
  chrome.runtime.sendMessage({ action: "fetchData" }, (response) => {
    if (response.data) {
      const messages = response.data.messages;
      messages.forEach((message) => {
        console.log(message);
      });
    } else if (response.error) {
      console.error("Error loading data:", response.error);
    }
  });
}

Add data to Firestore

function addData(data) {
  chrome.runtime.sendMessage({ action: "addData", data }, (response) => {
    if (response.id) {
      console.log("Data added with ID:", response.id);
    } else if (response.error) {
      console.error("Error adding data:", response.error);
    }
  });
}

Contributions

If you have any suggestions or improvements, please feel free to create a pull request or contact me.

Twitter Follow Linkedin

Happy coding!

chrome-extension-boilerplate's People

Contributors

adriman2 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.