MCPcopy Index your code
hub / github.com/ClearURLs/Addon / contextMenuStart

Function contextMenuStart

core_js/context_menu.js:25–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23*/
24
25function contextMenuStart() {
26 if(storage.contextMenuEnabled) {
27 browser.contextMenus.create({
28 id: "copy-link-to-clipboard",
29 title: translate("clipboard_copy_link"),
30 contexts: ["link"]
31 });
32
33 browser.contextMenus.onClicked.addListener((info, tab) => {
34 if (info.menuItemId === "copy-link-to-clipboard") {
35 const url = pureCleaning(info.linkUrl);
36 const code = "copyToClipboard(" +
37 JSON.stringify(url)+");";
38
39 browser.tabs.executeScript({
40 code: "typeof copyToClipboard === 'function';",
41 }).then((results) => {
42 if (!results || results[0] !== true) {
43 return browser.tabs.executeScript(tab.id, {
44 file: "/external_js/clipboard-helper.js",
45 }).catch(handleError);
46 }
47 }).then(() => {
48 return browser.tabs.executeScript(tab.id, {
49 code,
50 });
51 }).catch((error) => {
52 console.error("Failed to copy text: " + error);
53 });
54 }
55 });
56 }
57}

Callers 1

genesisFunction · 0.85

Calls 2

pureCleaningFunction · 0.85
translateFunction · 0.70

Tested by

no test coverage detected