aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2019-11-29 02:58:17 +0200
committersiikamiika <siikamiika@users.noreply.github.com>2019-11-29 02:58:17 +0200
commite3d96eb67de7ac5066c286511d0d15baa46f9610 (patch)
tree92737bbf0688a38f127818b80c99494a171002a3 /ext
parent8a94d186c33e3b4c8bf5caf14d2d7aad20e347cc (diff)
fix yomichan menu on Firefox Android
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/context.js32
1 files changed, 17 insertions, 15 deletions
diff --git a/ext/bg/js/context.js b/ext/bg/js/context.js
index 38a82636..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';
+ }
}
}