Pengin
Pengin

Reputation: 811

Messaging From Content Script/background To Injected Code?

I'm making a Chrome Extension.

I need to communicate between [content script ---> injected code] or [background ---> injected code].

injected code is one that injected via this method.

this answer says

Injected scripts behave as if they were included by the page itself, and are not connected to the extension in any way

Is this correct? Is there any single way to do this?

Upvotes: 0

Views: 159

Answers (1)

Sudarshan
Sudarshan

Reputation: 18534

You can use chrome.extension.sendMessage and it's listener to communicate from content scripts\injected scripts with back ground page and chrome.tabs.sendMessage with its listener to communicate from back ground page to content scripts\injected scripts

Upvotes: 1

Related Questions