// Fix Filebrowser download: remove target="_blank" and add download attribute // This prevents popup blockers from breaking downloads on shared pages (function() { function patchDownloadLinks() { // Patch download links on shared pages and in the main UI document.querySelectorAll('a[href*="/api/public/dl/"], a[href*="/api/raw/"]').forEach(function(link) { if (!link.hasAttribute('download')) { link.setAttribute('download', ''); } if (link.target === '_blank') { link.removeAttribute('target'); } }); } // Patch on DOM ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', patchDownloadLinks); } else { patchDownloadLinks(); } // Patch on DOM changes (SPA navigation, dynamic content) var observer = new MutationObserver(function() { patchDownloadLinks(); }); observer.observe(document.body || document.documentElement, { childList: true, subtree: true }); })();