Skip to content

Instantly share code, notes, and snippets.

@trungpv1601
Created June 7, 2023 03:38
Show Gist options
  • Save trungpv1601/00c9381a4a3eec8aea7162b7402dabd6 to your computer and use it in GitHub Desktop.
Save trungpv1601/00c9381a4a3eec8aea7162b7402dabd6 to your computer and use it in GitHub Desktop.
(function (c) {
c.runtime.onMessage.addListener(async function (
request,
sender,
sendResponse
) {
switch (request.type) {
case "EVENT_1":
// TODO: do something
break;
case "EVENT_2":
// TODO: do something
break;
default:
break;
}
return true;
});
})(chrome);
chrome.runtime.sendMessage({
type: "EVENT_1",
data: {hey: 'EVENT_1'},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment