From a5277f9f946b621e0a123e02929af3c08828361c Mon Sep 17 00:00:00 2001 From: ThinkStu <91378285+Bistutu@users.noreply.github.com> Date: Sat, 27 Apr 2024 09:02:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=BC=A0=E6=A0=87=E4=B8=AD?= =?UTF-8?q?=E9=94=AE=E7=82=B9=E5=87=BB=E7=BF=BB=E8=AF=91=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entrypoints/content.ts | 11 +++++++++++ entrypoints/utils/option.ts | 4 ++++ 2 files changed, 15 insertions(+) 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: [ {