MCPcopy Create free account
hub / github.com/zxlie/FeHelper / _createItem

Function _createItem

apps/background/menu.js:181–198  ·  view source on GitHub ↗
(toolName, menuList, parentId)

Source from the content-addressed store, hash-verified

179 * @private
180 */
181 let _createItem = (toolName, menuList, parentId) => {
182 menuList && menuList.forEach && menuList.forEach(menu => {
183
184 let menuItemId = 'fhm_c' + escape(menu.text).replace(/\W/g,'') + Date.now() + Math.floor(Math.random() * 1000);
185
186 chrome.contextMenus.create({
187 id: menuItemId,
188 title: menu.text,
189 contexts: menu.contexts || ['all'],
190 parentId: parentId || FeJson.contextMenuId
191 }, () => {
192 if (chrome.runtime.lastError) return;
193 FeJson.menuClickHandlers[menuItemId] = menu.onClick || (() => {
194 globalThis.FeHelperBg.DynamicToolRunner({ tool: toolName });
195 });
196 });
197 });
198 };
199
200 let _ensureToolMenuConfig = (tool, toolInfo) => {
201 if(!toolInfo.menuConfig) {

Callers 3

_buildToolMenusFunction · 0.85
_buildGroupedToolMenusFunction · 0.85
_buildSystemMenusFunction · 0.85

Calls 1

escapeFunction · 0.50

Tested by

no test coverage detected