diff options
| author | Kuuuube <61125188+Kuuuube@users.noreply.github.com> | 2024-06-14 05:41:53 -0400 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-14 09:41:53 +0000 | 
| commit | 591f75bbbcdff91610c4e5dfa57baae8d2c9f099 (patch) | |
| tree | 73c5ec2a20c59fd14e2940056d9843465d384545 | |
| parent | 01d2703b99f0dd55786d4f5b865cdfdef3cb335e (diff) | |
Error check context menu editing (#1063)
| -rw-r--r-- | ext/js/background/backend.js | 30 | 
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)); |