summaryrefslogtreecommitdiff
path: root/ext/js/background/backend.js
diff options
context:
space:
mode:
authorJames Maa <jmaa@berkeley.edu>2024-06-10 10:59:54 -0700
committerGitHub <noreply@github.com>2024-06-10 17:59:54 +0000
commite24075e1a91ab8b58bb5836cf7abcefae5cbf8c3 (patch)
tree57881c2de6a9d75185a390741d404d61d5c9ce69 /ext/js/background/backend.js
parent8eea3661714c64857aa32a8662f7cca6674dd3a4 (diff)
Add context menu interface for Yomitan (#1028)
* --wip-- [skip ci] * Draft * Remove weird code * Use existing API instead of dulpicating * Small improvements * remove console.log * remove console.log * Add setting for contextMenu * Fix test * Address comments * Add option-util upgrade * fix option-utils
Diffstat (limited to 'ext/js/background/backend.js')
-rw-r--r--ext/js/background/backend.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js
index a04566c9..88912b70 100644
--- a/ext/js/background/backend.js
+++ b/ext/js/background/backend.js
@@ -1310,6 +1310,21 @@ export class Backend {
this._clipboardMonitor.stop();
}
+ if (options.general.enableContextMenuScanSelected) {
+ chrome.contextMenus.create({
+ id: 'yomitan_lookup',
+ title: 'Lookup in Yomitan',
+ contexts: ['selection'],
+ });
+ chrome.contextMenus.onClicked.addListener((info) => {
+ if (info.selectionText) {
+ this._sendMessageAllTabsIgnoreResponse({action: 'frontendScanSelectedText'});
+ }
+ });
+ } else {
+ chrome.contextMenus.remove('yomitan_lookup', () => this._checkLastError(chrome.runtime.lastError));
+ }
+
void this._accessibilityController.update(this._getOptionsFull(false));
this._sendMessageAllTabsIgnoreResponse({action: 'applicationOptionsUpdated', params: {source}});