Skip to content

Commit

Permalink
Fix #128
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrews54757 committed Apr 13, 2024
1 parent 352c91f commit 7f53ebb
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions chrome/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ let FoundYTPlayer = null;
let OverridenYTKeys = false;
const iframeMap = new Map();
const players = [];
const elementsHiddenByFillscreen = [];
window.addEventListener('message', (e) => {
if (typeof e.data !== 'object') {
return;
Expand Down Expand Up @@ -252,6 +253,8 @@ function removePlayers() {
unmakeMiniPlayer(iframeObj);
});

undoFillScreenIframe();

players.forEach((player) => {
if (player.isYt) {
showYT(player.old);
Expand Down Expand Up @@ -385,13 +388,47 @@ function windowedFullscreenToggle(iframeObj) {
player.isWindowedFullscreen = false;
}
});
undoFillScreenIframe();
setTimeout(() => {
updatePlayerStyles();
}, 1000);
}
}

function undoFillScreenIframe() {
elementsHiddenByFillscreen.forEach((element) => {
element.style.display = element.dataset.olddisplay;
});
elementsHiddenByFillscreen.length = 0;
}

function fillScreenIframe(iframe) {
const elementsToHide = [];

// Gather all elements not parents of the iframe
const elements = document.querySelectorAll('*');
for (let i = 0; i < elements.length; i++) {
const element = elements[i];
if (element === iframe) {
continue;
}

if (element.contains(iframe)) {
continue;
}

elementsToHide.push(element);
}

elementsToHide.forEach((element) => {
if (element === iframe) {
return;
}
element.dataset.olddisplay = element.style.display;
element.style.setProperty('display', 'none', 'important');
elementsHiddenByFillscreen.push(element);
});

iframe.setAttribute('style', `
position: fixed !important;
display: block !important;
Expand Down

0 comments on commit 7f53ebb

Please sign in to comment.