From 591f75bbbcdff91610c4e5dfa57baae8d2c9f099 Mon Sep 17 00:00:00 2001 From: Kuuuube <61125188+Kuuuube@users.noreply.github.com> Date: Fri, 14 Jun 2024 05:41:53 -0400 Subject: Error check context menu editing (#1063) --- ext/js/background/backend.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'ext') 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)); -- cgit v1.2.3