* feat(build): inline chrome-extension-toolkit fix: tsconfig docs: add chrome-extension-toolkit README.md chore: update imports fix: stores fix: chrome-extension-toolkit ForegroundMessenger fix: calendarBackgroundHandler fix: format and lint fix: path alias fix: add jsdom env and fix imports Co-authored-by: Sriram Hariharan <sghsri@gmail.com> * build: vite storybook config crx toolkit line --------- Co-authored-by: Sriram Hariharan <sghsri@gmail.com> Co-authored-by: Derek <derex1987@gmail.com>
15 lines
591 B
TypeScript
15 lines
591 B
TypeScript
/**
|
|
* A content script can be invalidated if a chrome extension is reloaded / updated.
|
|
* This function is used to detect when the extension's context has been invalidated, and to call a callback.
|
|
* @param callback A callback to be called when the extension's context has been invalidated
|
|
*/
|
|
export function onContextInvalidated(callback: () => void) {
|
|
const interval = setInterval(() => {
|
|
// this means the current tab's context has been invalidated
|
|
if (!chrome.runtime.id) {
|
|
clearInterval(interval);
|
|
callback();
|
|
}
|
|
}, 1 * 1000);
|
|
}
|