Skip to content

Instantly share code, notes, and snippets.

@oops-wrong
Created May 27, 2024 18:51
Show Gist options
  • Save oops-wrong/bc4afd80a862f06dcdd79d36d66a9222 to your computer and use it in GitHub Desktop.
Save oops-wrong/bc4afd80a862f06dcdd79d36d66a9222 to your computer and use it in GitHub Desktop.
const messageToBackground = (type, payload) => {
chrome.runtime.sendMessage({
type,
payload,
});
};
const resendBackgroundMessages = () => {
window.addEventListener(
'message',
(e) => {
if (e.data?.toBackground) {
messageToBackground(e.data?.type, e.data?.payload);
}
},
false,
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment