Code interacting with browser extensions can live in four places:
- Background scripts
- Content scripts
- Injected scripts
- Your web app
This Stack Overflow answer has a great shorthand explanation for each. It also might help to start by taking a look at the minimum viable Chrome Extension.
This repo demonstrates how to use a content script to enable your web app to talk to the extension's background script, which has full access to the chrome.*
APIs.
Learn how to create a build process and the basics of mapping Chrome resources to Safari and Firefox in Developing Cross Browser Extensions by @alexbeletsky.