-2

I want to know how my content script can communicate with the backend script. I mean sending request from content script and get responce from backend script based on request.

1 Answers1

0

You should refer to message passing: https://developer.chrome.com/extensions/messaging

When sending a message from content script to background script you'll simply use:

chrome.runtime.sendMessage({greeting: "hello"}, function(response) {
  console.log(response.farewell);
});

When it's the other way around you'll need to specify the tab as well (please refer to the link above).

Eran
  • 133
  • 7