← Commit history

adom-video: open the full-window tab through a link (window.open noopener returns null)

John Lauer ·ce1ca859c7 ·7d ago ·parent 9422382
1 file changed +5−3
widgets/video-widget.js+5−3
@@ -489,9 +489,11 @@       if (location.pathname.includes('/widget/')) { const u = new URL(location.href); u.searchParams.set('start', String(t)); url = u.href; }       else url = (this.v.currentSrc || this.v.src).split('#')[0] + `#t=${t}`;       this.v.pause();-      const w = window.open(url, '_blank', 'noopener');-      if (!w) this._hud('Your browser blocked the new tab');+      this._openTab(url);+      this._hud('Opened in a new tab');     }+    // window.open with noopener always returns null, so open through a link (the frame allows popups)+    _openTab(url) { const a = document.createElement('a'); a.href = url; a.target = '_blank'; a.rel = 'noopener'; this.shadowRoot.appendChild(a); a.click(); a.remove(); }     async fullscreen() {       if (document.fullscreenElement) { await document.exitFullscreen().catch(() => {}); return; }       if (document.fullscreenEnabled && this.p.requestFullscreen) {@@ -668,7 +670,7 @@         else if (b.dataset.act === 'cc') this.captions();         else if (b.dataset.act === 'loop') this.loop();         else if (b.dataset.act === 'keys') this._help(true);-        else if (b.dataset.act === 'dl') { window.open((v.currentSrc || v.src).split('#')[0], '_blank', 'noopener'); this._menuClose(); }+        else if (b.dataset.act === 'dl') { this._openTab((v.currentSrc || v.src).split('#')[0]); this._menuClose(); }       });        // YouTube's keyboard shortcuts, for whichever player owns the keyboard