Skip to content

Commit

Permalink
Put if check over whole block
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuuuube committed Dec 17, 2024
1 parent 9251f28 commit a5fac51
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions ext/js/background/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -1331,19 +1331,21 @@ export class Backend {
}

try {
if (options.general.enableContextMenuScanSelected && chrome.contextMenus) {
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));
if (chrome.contextMenus) {
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);
Expand Down

0 comments on commit a5fac51

Please sign in to comment.