Skip to content

Commit

Permalink
Merge pull request #4 from loskael/main
Browse files Browse the repository at this point in the history
Resolve copyStyleSheets option removed
  • Loading branch information
lazy-guy authored Sep 5, 2023
2 parents 0780d54 + f4c98cf commit 6d4c266
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,26 @@ if ('documentPictureInPicture' in window) {

pipWindow = await documentPictureInPicture.requestWindow(pipOptions);

// Copy style sheets over from the initial document
// so that the player looks the same.
[...document.styleSheets].forEach((styleSheet) => {
try {
const cssRules = [...styleSheet.cssRules].map((rule) => rule.cssText).join('');
const style = document.createElement('style');

style.textContent = cssRules;
pipWindow.document.head.appendChild(style);
} catch (e) {
const link = document.createElement('link');

link.rel = 'stylesheet';
link.type = styleSheet.type;
link.media = styleSheet.media;
link.href = styleSheet.href;
pipWindow.document.head.appendChild(link);
}
});

// Add timer to the PiP window.
pipWindow.document.body.append(timer);

Expand Down

0 comments on commit 6d4c266

Please sign in to comment.