aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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));