diff --git a/entrypoints/content.ts b/entrypoints/content.ts index 0f4615c..43af04b 100644 --- a/entrypoints/content.ts +++ b/entrypoints/content.ts @@ -67,6 +67,17 @@ export default defineContentScript({ }, 500) as unknown as number; }); + // 8、鼠标中键翻译事件 + document.body.addEventListener('click', event => { + if (config.hotkey===constants.MiddleClick) { + if (event.button === 1) { + let mouseX = event.clientX; + let mouseY = event.clientY; + handler(config, mouseX, mouseY); + } + } + }); + // background.ts browser.runtime.onMessage.addListener((message, sender, sendResponse) => { diff --git a/entrypoints/utils/option.ts b/entrypoints/utils/option.ts index d51b0cf..aa8c7ac 100644 --- a/entrypoints/utils/option.ts +++ b/entrypoints/utils/option.ts @@ -117,6 +117,10 @@ export const options = { value: 'LongPress', label: "鼠标长按" }, + { + value: 'MiddleClick', + label: "鼠标中键" + } ], services: [ {