refactor: clipper screenshot (#2325)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { runtime, action, browserAction, windows, storage } from 'webextension-polyfill'
|
||||
import { runtime, action, browserAction, windows, storage, tabs } from 'webextension-polyfill'
|
||||
import { ClipPayload, RuntimeMessage, RuntimeMessageTypes } from '../types/message'
|
||||
|
||||
const isFirefox = navigator.userAgent.indexOf('Firefox/') !== -1
|
||||
@@ -22,11 +22,15 @@ const openPopupAndClipSelection = async (payload: ClipPayload) => {
|
||||
void openPopup()
|
||||
}
|
||||
|
||||
runtime.onMessage.addListener((message: RuntimeMessage) => {
|
||||
runtime.onMessage.addListener(async (message: RuntimeMessage) => {
|
||||
if (message.type === RuntimeMessageTypes.OpenPopupWithSelection) {
|
||||
if (!message.payload) {
|
||||
return
|
||||
}
|
||||
void openPopupAndClipSelection(message.payload)
|
||||
} else if (message.type === RuntimeMessageTypes.CaptureVisibleTab) {
|
||||
return await tabs.captureVisibleTab(undefined, {
|
||||
format: 'png',
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user