Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hindmost/fea7e57b90f8c1ee6c9f52e5310de411 to your computer and use it in GitHub Desktop.
Save hindmost/fea7e57b90f8c1ee6c9f52e5310de411 to your computer and use it in GitHub Desktop.
cra-rich-chrome-ext article: src/background.js - modifications
...
chrome.tabs.onActivated.addListener(async data => {
const {tabId} = data;
if (!tabId)
return;
const store = await getStore();
const state = store.getState();
const {account, marker} = state;
const toMark = account.keywords && marker.enabled;
if (!toMark)
return;
// reset marker stats:
store.dispatch(setStats(false));
// pass focus to active tab:
chrome.tabs.sendMessage(tabId, {id: 'tabFocusPass'});
});
(async () => {
...
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment