From 7ded95ac872433d6d1912bc52783c36bda0e026d Mon Sep 17 00:00:00 2001 From: Victor Azevedo <34415964+victrme@users.noreply.github.com> Date: Mon, 30 Sep 2024 11:40:42 +0200 Subject: [PATCH] "Open in new tab" removed for Safari --- src/scripts/features/links/index.ts | 26 ++++---------------------- src/settings.html | 10 ++++++---- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/scripts/features/links/index.ts b/src/scripts/features/links/index.ts index 5f272e90..8750bdb4 100644 --- a/src/scripts/features/links/index.ts +++ b/src/scripts/features/links/index.ts @@ -271,11 +271,7 @@ function createElem(link: Links.Elem, openInNewtab: boolean, style: Style) { } if (openInNewtab) { - if (BROWSER === 'safari') { - anchor.onclick = handleSafariNewtab - } else { - anchor.target = '_blank' - } + anchor.target = '_blank' } return li @@ -612,18 +608,10 @@ function setOpenInNewTab(newtab: boolean, data: Sync.Storage): Sync.Storage { const anchors = document.querySelectorAll('.link a') for (const anchor of anchors) { - if (BROWSER === 'safari') { - if (newtab) { - anchor.addEventListener('click', handleSafariNewtab) - } else { - anchor.removeEventListener('click', handleSafariNewtab) - } + if (newtab) { + anchor.setAttribute('target', '_blank') } else { - if (newtab) { - anchor.setAttribute('target', '_blank') - } else { - anchor.removeAttribute('target') - } + anchor.removeAttribute('target') } } @@ -682,12 +670,6 @@ function setRows(row: string) { eventDebounce({ linksrow: row }) } -function handleSafariNewtab(e: Event) { - const anchor = e.composedPath().filter((el) => (el as Element).tagName === 'A')[0] - window.open((anchor as HTMLAnchorElement)?.href) - e.preventDefault() -} - // Helpers export function validateLink(title: string, url: string, parent?: string): Links.Elem { diff --git a/src/settings.html b/src/settings.html index c02923f2..ac4c82ba 100644 --- a/src/settings.html +++ b/src/settings.html @@ -284,11 +284,13 @@

Quick Links

>

-
+
+
-
- - +
+ + +