fix yomichan menu on Firefox Android

This commit is contained in:
siikamiika 2019-11-29 02:58:17 +02:00
parent 8a94d186c3
commit e3d96eb67d

View File

@ -26,22 +26,24 @@ function showExtensionInfo() {
} }
function setupButtonEvents(selector, command, url) { function setupButtonEvents(selector, command, url) {
const node = document.querySelector(selector); const nodes = document.querySelectorAll(selector);
node.addEventListener('click', (e) => { for (const node of nodes) {
if (e.button !== 0) { return; } node.addEventListener('click', (e) => {
apiCommandExec(command, {newTab: e.ctrlKey}); if (e.button !== 0) { return; }
e.preventDefault(); apiCommandExec(command, {newTab: e.ctrlKey});
}, false); e.preventDefault();
node.addEventListener('auxclick', (e) => { }, false);
if (e.button !== 1) { return; } node.addEventListener('auxclick', (e) => {
apiCommandExec(command, {newTab: true}); if (e.button !== 1) { return; }
e.preventDefault(); apiCommandExec(command, {newTab: true});
}, false); e.preventDefault();
}, false);
if (typeof url === 'string') { if (typeof url === 'string') {
node.href = url; node.href = url;
node.target = '_blank'; node.target = '_blank';
node.rel = 'noopener'; node.rel = 'noopener';
}
} }
} }