Created
September 2, 2017 18:13
-
-
Save josephschmitt/f0a3ab7057b0632dfb4b2bc233769077 to your computer and use it in GitHub Desktop.
Stops the Plex web app from blocking right-click on the video to enter Picture in Picture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (plex) { | |
let timeout; | |
plex.addEventListener('contextmenu', (e) => { | |
const button = plex.querySelector('[class*="AudioVideoFullPlayer-isVideo"]'); | |
const miniPlayer = plex.querySelector('[class*="MiniPlayerContainer-miniPlayer"]') | |
const wasVideoBlocked = (button && button.contains(e.target) || (miniPlayer && miniPlayer.contains(e.target))); | |
toggleBlock(wasVideoBlocked, button, miniPlayer); | |
}); | |
function toggleBlock(disableBlock, button, miniPlayer) { | |
if (button) { | |
button.style.pointerEvents = disableBlock ? 'none' : ''; | |
} | |
if (miniPlayer) { | |
miniPlayer.style.pointerEvents = disableBlock ? 'none' : ''; | |
} | |
// Reset after a few secs | |
if (disableBlock) { | |
clearTimeout(timeout); | |
timeout = setTimeout(() => toggleBlock(false, button, miniPlayer), 3000) | |
} | |
} | |
})(document.querySelector('#plex')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment