refactor: Replace Webpack with Vite (#53)
This commit is contained in:
20
src/pages/background/handler/browserActionHandler.ts
Normal file
20
src/pages/background/handler/browserActionHandler.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import BrowserActionMessages from '@shared/messages/BrowserActionMessages';
|
||||
import { MessageHandler } from 'chrome-extension-toolkit';
|
||||
|
||||
const browserActionHandler: MessageHandler<BrowserActionMessages> = {
|
||||
disableBrowserAction({ sender, sendResponse }) {
|
||||
// by setting the popup to an empty string, clicking the browser action will not open the popup.html.
|
||||
// we can then add an onClickListener to it from the content script
|
||||
chrome.action.setPopup({ tabId: sender.tab?.id, popup: '' }).then(sendResponse);
|
||||
},
|
||||
enableBrowserAction({ sender, sendResponse }) {
|
||||
chrome.action
|
||||
.setPopup({
|
||||
tabId: sender.tab?.id,
|
||||
popup: 'popup.html',
|
||||
})
|
||||
.then(sendResponse);
|
||||
},
|
||||
};
|
||||
|
||||
export default browserActionHandler;
|
||||
Reference in New Issue
Block a user