forked from mxx1111/mdlook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.ts
More file actions
36 lines (33 loc) · 1.08 KB
/
Copy pathbackground.ts
File metadata and controls
36 lines (33 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { browser, defineBackground } from '#imports'
export default defineBackground({
type: `module`,
main() {
browser.runtime.onInstalled.addListener((detail) => {
if (import.meta.env.COMMAND === `serve`) {
browser.runtime.openOptionsPage()
return
}
if (detail.reason === `install`) {
browser.tabs.create({ url: `https://github.com/mxx1111/mdlook/blob/main/docs/browser-extension-wechat-images.md` })
}
else if (detail.reason === `update`) {
browser.runtime.openOptionsPage()
}
})
browser.runtime.onInstalled.addListener(() => {
if (typeof browser.sidePanel === `undefined`)
return
browser.contextMenus.create({
id: `openSidePanel`,
title: `打开 mdlook 公众号排版`,
documentUrlPatterns: [`https://mp.weixin.qq.com/cgi-bin/appmsg*`],
contexts: [`all`],
})
})
browser.contextMenus.onClicked.addListener((info, tab) => {
if (info.menuItemId === `openSidePanel`) {
browser.sidePanel.open({ tabId: tab!.id! })
}
})
},
})