background tab also when the user use ctrl or meta

This commit is contained in:
Mylloon 2024-01-19 12:15:44 +01:00
parent d485946d56
commit 465cc71e9e
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -48,13 +48,7 @@
/* Open cards link */ /* Open cards link */
const openLink = (url) => { const openLink = (url) => {
switch (event.button) { const backgroundtab = () =>
case 0:
/* Left click */
window.open(url, "_blank", "noreferrer");
break;
case 1:
/* Middle click */
Object.assign(document.createElement("a"), { Object.assign(document.createElement("a"), {
href: url, href: url,
target: "_blank", target: "_blank",
@ -62,6 +56,20 @@
}).dispatchEvent( }).dispatchEvent(
new MouseEvent("click", { ctrlKey: true, metaKey: true }) new MouseEvent("click", { ctrlKey: true, metaKey: true })
); );
switch (event.button) {
case 0:
/* Left click */
if (event.ctrlKey || event.metaKey) {
backgroundtab();
} else {
window.open(url, "_blank", "noreferrer");
}
break;
case 1:
/* Middle click */
backgroundtab();
break; break;
default: default:
break; break;