MCPcopy Create free account
hub / github.com/ChatGPTBox-dev/chatGPTBox / refreshMenu

Function refreshMenu

src/background/menus.mjs:110–152  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

108 })
109}
110export function refreshMenu() {
111 if (Browser.contextMenus.onClicked.hasListener(onClickMenu))
112 Browser.contextMenus.onClicked.removeListener(onClickMenu)
113 Browser.contextMenus.removeAll().then(async () => {
114 if ((await getUserConfig()).hideContextMenu) return
115
116 await getPreferredLanguageKey().then((lang) => {
117 changeLanguage(lang)
118 })
119 Browser.contextMenus.create({
120 id: menuId,
121 title: 'ChatGPTBox',
122 contexts: ['all'],
123 })
124
125 for (const [k, v] of Object.entries(menuConfig)) {
126 Browser.contextMenus.create({
127 id: menuId + k,
128 parentId: menuId,
129 title: t(v.label),
130 contexts: ['all'],
131 })
132 }
133 Browser.contextMenus.create({
134 id: menuId + 'separator1',
135 parentId: menuId,
136 contexts: ['selection'],
137 type: 'separator',
138 })
139 for (const index in defaultConfig.selectionTools) {
140 const key = defaultConfig.selectionTools[index]
141 const desc = defaultConfig.selectionToolsDesc[index]
142 Browser.contextMenus.create({
143 id: menuId + key,
144 parentId: menuId,
145 title: t(desc),
146 contexts: ['selection'],
147 })
148 }
149
150 Browser.contextMenus.onClicked.addListener(onClickMenu)
151 })
152}

Callers 1

index.mjsFile · 0.90

Calls 3

getUserConfigFunction · 0.90
getPreferredLanguageKeyFunction · 0.90
tFunction · 0.85

Tested by

no test coverage detected