diff --git a/src/entries/background.ts b/src/entries/background.ts index 34f6679..1f0de4b 100644 --- a/src/entries/background.ts +++ b/src/entries/background.ts @@ -194,6 +194,61 @@ export default defineBackground({ browser.tabs.create({ url: browser.runtime.getURL("/options.html") }) + } else if (info.menuItemId === "summarize-pa") { + if (!isCopilotRunning) { + browser.sidebarAction.toggle() + } + setTimeout(async () => { + await browser.runtime.sendMessage({ + from: "background", + type: "summary", + text: info.selectionText + }) + }, isCopilotRunning ? 0 : 5000) + } else if (info.menuItemId === "rephrase-pa") { + if (!isCopilotRunning) { + browser.sidebarAction.toggle() + } + setTimeout(async () => { + await browser.runtime.sendMessage({ + type: "rephrase", + from: "background", + text: info.selectionText + }) + }, isCopilotRunning ? 0 : 5000) + } else if (info.menuItemId === "translate-pg") { + if (!isCopilotRunning) { + browser.sidebarAction.toggle() + } + setTimeout(async () => { + await browser.runtime.sendMessage({ + type: "translate", + from: "background", + text: info.selectionText + }) + }, isCopilotRunning ? 0 : 5000) + } else if (info.menuItemId === "explain-pa") { + if (!isCopilotRunning) { + browser.sidebarAction.toggle() + } + setTimeout(async () => { + await browser.runtime.sendMessage({ + type: "explain", + from: "background", + text: info.selectionText + }) + }, isCopilotRunning ? 0 : 5000) + } else if (info.menuItemId === "custom-pg") { + if (!isCopilotRunning) { + browser.sidebarAction.toggle() + } + setTimeout(async () => { + await browser.runtime.sendMessage({ + type: "custom", + from: "background", + text: info.selectionText + }) + }, isCopilotRunning ? 0 : 5000) } }) diff --git a/src/services/application.ts b/src/services/application.ts index 6543618..63a860d 100644 --- a/src/services/application.ts +++ b/src/services/application.ts @@ -23,7 +23,7 @@ Ensure that your rephrased version conveys the same information and intent as th Response:` -const DEFAULT_TRANSLATE_PROMPT = `Translate the following text from its original language into "english"0. Maintain the tone and style of the original text as much as possible: +const DEFAULT_TRANSLATE_PROMPT = `Translate the following text from its original language into "english". Maintain the tone and style of the original text as much as possible: Text: ---------