Skip to content

Commit

Permalink
添加鼠标中键点击翻译事件
Browse files Browse the repository at this point in the history
  • Loading branch information
Bistutu committed Apr 27, 2024
1 parent ec917c3 commit a5277f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions entrypoints/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 4 additions & 0 deletions entrypoints/utils/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ export const options = {
value: 'LongPress',
label: "鼠标长按"
},
{
value: 'MiddleClick',
label: "鼠标中键"
}
],
services: [
{
Expand Down

0 comments on commit a5277f9

Please sign in to comment.