0

on every page I am injecting a widget (html + javascript). Later when I click on a button, I want the widget to send a message to the extension service_worker.

to use this :

chrome.runtime.sendMessage('extension_id', { foo: 'bar' },
    function (response) {
        console.log(response);
    }
);

I need to add this in the manifest.js

"externally_connectable": {
    "matches": [
      "https://*.example.com/*"
    ]
}

But want it to work on every website, and as said here I can't use "<all_urls>".

Is there another way to comunicate with my extemsion from the widget I injected in a webpage ?

Thanks !

cbdev
  • 21
  • 3
  • Use CustomEvent between your page and a content script of your extension that runs on all sites. – wOxxOm Apr 05 '22 at 14:26

0 Answers0