Skip to content

Commit

Permalink
Update player.js
Browse files Browse the repository at this point in the history
fixed #1812
  • Loading branch information
MAZ01001 committed Oct 31, 2023
1 parent c93c09f commit 15ffa03
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions js&css/web-accessible/www.youtube.com/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,11 +728,19 @@ ImprovedTube.playerPopupButton = function () {

player.pauseVideo();

let urlPopup = `${location.protocol}//www.youtube.com/embed/${location.search.match(ImprovedTube.regex.video_id)[1]}?start=${parseInt(player.getCurrentTime())}&autoplay=${(ImprovedTube.storage.player_autoplay ?? true) ? '1' : '0'}`;
const videoID = location.search.match(ImprovedTube.regex.video_id)[1];

let urlPopup = `${location.protocol}//www.youtube.com/embed/${videoID}?start=${parseInt(player.getCurrentTime())}&autoplay=${(ImprovedTube.storage.player_autoplay ?? true) ? '1' : '0'}`;
const listMatch = location.search.match(ImprovedTube.regex.playlist_id);
if (listMatch) urlPopup += `&list=${listMatch[1]}`;

window.open(urlPopup, '_blank', `directories=no,toolbar=no,location=no,menubar=no,status=no,titlebar=no,scrollbars=no,resizable=no,width=${player.offsetWidth},height=${player.offsetHeight}`);
const popup = window.open(urlPopup, '_blank', `directories=no,toolbar=no,location=no,menubar=no,status=no,titlebar=no,scrollbars=no,resizable=no,width=${player.offsetWidth},height=${player.offsetHeight}`);
if(popup && listMatch){
popup.addEventListener('load', function () {
const videoLink = popup.document.querySelector('div#player div.ytp-title-text>a[href]');
if (videoLink && videoLink.href.match(ImprovedTube.regex.video_id)[1] !== videoID) popup.location.search = popup.location.search.replace(/(\?)list=[^&]+&|&list=[^&]+/, '$1');
}, {passive: true, once: true});
}
},
title: 'Popup'
});
Expand Down

0 comments on commit 15ffa03

Please sign in to comment.