forked from Archives/Athou_commafeed
add buttons that communicate with the browser extension (Athou/commafeed-browser-extension#1)
This commit is contained in:
9
commafeed-client/src/hooks/useBrowserExtension.ts
Normal file
9
commafeed-client/src/hooks/useBrowserExtension.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export const useBrowserExtension = () => {
|
||||
// when not in an iframe, window.parent is a reference to window
|
||||
const isBrowserExtension = window.parent !== window
|
||||
|
||||
const openSettingsPage = () => window.parent.postMessage("open-settings-page", "*")
|
||||
const openAppInNewTab = () => window.parent.postMessage("open-app-in-new-tab", "*")
|
||||
|
||||
return { isBrowserExtension, openSettingsPage, openAppInNewTab }
|
||||
}
|
||||
Reference in New Issue
Block a user