summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorKuuuube <61125188+Kuuuube@users.noreply.github.com>2024-06-14 05:41:53 -0400
committerGitHub <noreply@github.com>2024-06-14 09:41:53 +0000
commit591f75bbbcdff91610c4e5dfa57baae8d2c9f099 (patch)
tree73c5ec2a20c59fd14e2940056d9843465d384545 /ext
parent01d2703b99f0dd55786d4f5b865cdfdef3cb335e (diff)
Error check context menu editing (#1063)
Diffstat (limited to 'ext')
-rw-r--r--ext/js/background/backend.js30
1 files changed, 17 insertions, 13 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js
index 57e934c5..a468a3f6 100644
--- a/ext/js/background/backend.js
+++ b/ext/js/background/backend.js
@@ -1310,19 +1310,23 @@ export class Backend {
this._clipboardMonitor.stop();
}
- if (options.general.enableContextMenuScanSelected) {
- chrome.contextMenus.create({
- id: 'yomitan_lookup',
- title: 'Lookup in Yomitan',
- contexts: ['selection'],
- }, () => this._checkLastError(chrome.runtime.lastError));
- chrome.contextMenus.onClicked.addListener((info) => {
- if (info.selectionText) {
- this._sendMessageAllTabsIgnoreResponse({action: 'frontendScanSelectedText'});
- }
- });
- } else {
- chrome.contextMenus.remove('yomitan_lookup', () => this._checkLastError(chrome.runtime.lastError));
+ try {
+ if (options.general.enableContextMenuScanSelected) {
+ chrome.contextMenus.create({
+ id: 'yomitan_lookup',
+ title: 'Lookup in Yomitan',
+ contexts: ['selection'],
+ }, () => this._checkLastError(chrome.runtime.lastError));
+ chrome.contextMenus.onClicked.addListener((info) => {
+ if (info.selectionText) {
+ this._sendMessageAllTabsIgnoreResponse({action: 'frontendScanSelectedText'});
+ }
+ });
+ } else {
+ chrome.contextMenus.remove('yomitan_lookup', () => this._checkLastError(chrome.runtime.lastError));
+ }
+ } catch (e) {
+ log.error(e);
}
void this._accessibilityController.update(this._getOptionsFull(false));