Reputation: 11
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
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