diff --git a/plugins/opener/guest-js/init.ts b/plugins/opener/guest-js/init.ts index b77c7452..d2070e8e 100644 --- a/plugins/opener/guest-js/init.ts +++ b/plugins/opener/guest-js/init.ts @@ -6,14 +6,7 @@ import { invoke } from '@tauri-apps/api/core' // open links with the API window.addEventListener('click', function (evt) { - if ( - evt.defaultPrevented || - evt.button !== 0 || - evt.metaKey || - evt.altKey || - evt.ctrlKey || - evt.shiftKey - ) + if (evt.defaultPrevented || evt.button !== 0 || evt.metaKey || evt.altKey) return const a = evt @@ -22,8 +15,13 @@ window.addEventListener('click', function (evt) { | HTMLAnchorElement | undefined - // only open if supposed to be open in a new tab - if (!a || !a.href || a.target !== '_blank') return + if ( + !a || + !a.href || + // only open if supposed to be open in a new tab + !(a.target === '_blank' || evt.ctrlKey || evt.shiftKey) + ) + return const url = new URL(a.href) diff --git a/plugins/opener/src/init-iife.js b/plugins/opener/src/init-iife.js index 4703edc8..ac75587c 100644 --- a/plugins/opener/src/init-iife.js +++ b/plugins/opener/src/init-iife.js @@ -1 +1 @@ -!function(){"use strict";"function"==typeof SuppressedError&&SuppressedError,window.addEventListener("click",(function(e){if(e.defaultPrevented||0!==e.button||e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)return;const t=e.composedPath().find((e=>e instanceof Node&&"A"===e.nodeName.toUpperCase()));if(!t||!t.href||"_blank"!==t.target)return;const n=new URL(t.href);n.origin===window.location.origin||["http:","https:","mailto:","tel:"].every((e=>n.protocol!==e))||(e.preventDefault(),async function(e,t={},n){window.__TAURI_INTERNALS__.invoke(e,t,n)}("plugin:opener|open_url",{path:n}))}))}(); +!function(){"use strict";"function"==typeof SuppressedError&&SuppressedError,window.addEventListener("click",(function(e){if(e.defaultPrevented||0!==e.button||e.metaKey||e.altKey)return;const t=e.composedPath().find((e=>e instanceof Node&&"A"===e.nodeName.toUpperCase()));if(!t||!t.href||"_blank"!==t.target&&!e.ctrlKey&&!e.shiftKey)return;const n=new URL(t.href);n.origin===window.location.origin||["http:","https:","mailto:","tel:"].every((e=>n.protocol!==e))||(e.preventDefault(),async function(e,t={},n){window.__TAURI_INTERNALS__.invoke(e,t,n)}("plugin:opener|open_url",{path:n}))}))}();