diff --git a/web/app.js b/web/app.js index 88f9031..5466a6c 100644 --- a/web/app.js +++ b/web/app.js @@ -1512,6 +1512,32 @@ function openBookmarkQueries(baseQuery) { return opened; } +function bindMiddleMouseOpen(element, handler) { + if (!element || typeof handler !== 'function') { + return; + } + + // Prevent browser auto-scroll so middle click behaves like link-open here. + element.addEventListener('mousedown', (event) => { + if (event.button === 1) { + event.preventDefault(); + } + }); + + element.addEventListener('auxclick', (event) => { + if (event.button !== 1) { + return; + } + event.preventDefault(); + event.stopPropagation(); + handler(); + }); +} + +if (typeof window !== 'undefined') { + window.bindMiddleMouseOpen = bindMiddleMouseOpen; +} + function openBookmark(bookmark) { if (!bookmark) { return; @@ -1611,7 +1637,9 @@ function createBookmarkRow(bookmark) { openButton.title = searchVariants.map((variant) => `• ${variant}`).join('\n'); } - openButton.addEventListener('click', () => openBookmark(bookmark)); + const handleOpenBookmark = () => openBookmark(bookmark); + openButton.addEventListener('click', handleOpenBookmark); + bindMiddleMouseOpen(openButton, handleOpenBookmark); const label = document.createElement('span'); label.className = 'bookmark-row__label'; diff --git a/web/daily-bookmarks.js b/web/daily-bookmarks.js index 5fc9132..eaba122 100644 --- a/web/daily-bookmarks.js +++ b/web/daily-bookmarks.js @@ -808,13 +808,17 @@ openBtn.textContent = '🔗'; openBtn.title = isActive ? 'Öffnen' : 'Deaktiviert'; openBtn.disabled = !isActive; - openBtn.addEventListener('click', () => { + const handleOpenBookmark = () => { const target = item.resolved_url || item.url_template; if (!isActive) return; if (target) { window.open(target, '_blank', 'noopener'); } - }); + }; + openBtn.addEventListener('click', handleOpenBookmark); + if (typeof window.bindMiddleMouseOpen === 'function') { + window.bindMiddleMouseOpen(openBtn, handleOpenBookmark); + } actionsTd.appendChild(openBtn); const toggleBtn = document.createElement('button'); diff --git a/web/trade-fairs.js b/web/trade-fairs.js index b8b6f2b..2a99b70 100644 --- a/web/trade-fairs.js +++ b/web/trade-fairs.js @@ -1650,13 +1650,17 @@ button.className = 'bookmark-subpage__messe-link'; button.textContent = query; button.title = getTradeFairHoverTitle(row); - button.addEventListener('click', () => { + const handleOpenTradeFair = () => { const opened = openTradeFairSearch(row, query); if (opened > 0) { button.title = getTradeFairHoverTitle(row); render(); } - }); + }; + button.addEventListener('click', handleOpenTradeFair); + if (typeof window.bindMiddleMouseOpen === 'function') { + window.bindMiddleMouseOpen(button, handleOpenTradeFair); + } linksWrap.appendChild(button); if (index < bookmarkQueries.length - 1) {