diff options
Diffstat (limited to 'ext/bg/js/context.js')
-rw-r--r-- | ext/bg/js/context.js | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/ext/bg/js/context.js b/ext/bg/js/context.js index b288a79a..0b21f662 100644 --- a/ext/bg/js/context.js +++ b/ext/bg/js/context.js @@ -26,22 +26,24 @@ function showExtensionInfo() { } function setupButtonEvents(selector, command, url) { - const node = document.querySelector(selector); - node.addEventListener('click', (e) => { - if (e.button !== 0) { return; } - apiCommandExec(command, {newTab: e.ctrlKey}); - e.preventDefault(); - }, false); - node.addEventListener('auxclick', (e) => { - if (e.button !== 1) { return; } - apiCommandExec(command, {newTab: true}); - e.preventDefault(); - }, false); + const nodes = document.querySelectorAll(selector); + for (const node of nodes) { + node.addEventListener('click', (e) => { + if (e.button !== 0) { return; } + apiCommandExec(command, {newTab: e.ctrlKey}); + e.preventDefault(); + }, false); + node.addEventListener('auxclick', (e) => { + if (e.button !== 1) { return; } + apiCommandExec(command, {newTab: true}); + e.preventDefault(); + }, false); - if (typeof url === 'string') { - node.href = url; - node.target = '_blank'; - node.rel = 'noopener'; + if (typeof url === 'string') { + node.href = url; + node.target = '_blank'; + node.rel = 'noopener'; + } } } @@ -63,7 +65,7 @@ window.addEventListener('DOMContentLoaded', () => { depth: 0, url: window.location.href }; - apiOptionsGet(optionsContext).then(options => { + apiOptionsGet(optionsContext).then((options) => { const toggle = document.querySelector('#enable-search'); toggle.checked = options.general.enable; toggle.addEventListener('change', () => apiCommandExec('toggle'), false); |