ApeSander
ApeSander

Reputation: 11

How to run code isolated from the site context?

I am trying to build a chrome extension, I need to call a function from the isolated world to another script which is not in the sites context (like the background script for example). How should I go about this?

I tried calling the function inside the sites context, but for some reason when I fetch the websites api it requires the user to be logged out while other parts in my program require the user to be logged in.

Upvotes: 0

Views: 23

Answers (1)

WofWca
WofWca

Reputation: 706

To communicate between different scripts of your extension, you need to utilize messaging (browser.runtime.sendMessage() and browser.runtime.onMessage.addListener()).

This communication uses message passing, which allows both extensions and content scripts to listen for each other's messages and respond on the same channel.

Upvotes: 0

Related Questions