Skip to content

Instantly share code, notes, and snippets.

@klzns
Last active July 2, 2018 15:11
Show Gist options
  • Save klzns/af95868fc61939d0f1ab9cb4aaa29626 to your computer and use it in GitHub Desktop.
Save klzns/af95868fc61939d0f1ab9cb4aaa29626 to your computer and use it in GitHub Desktop.
Adicione esse script para abrir a transmissão da copa em picture in picture no Safari.
(function () {
var video = document.querySelector('video:not([title="Advertisement"])')
if (!video.webkitSupportsPresentationMode || typeof video.webkitSetPresentationMode !== 'function') {
console.error('Esse código só funciona no Safari!')
return
}
var scoreX = document.querySelector('.placar__equipes')
var button = document.createElement('button')
button.innerHTML = 'Abrir Picture-in-Picture'
button.style.cssText='font-size: 1.3rem; margin:0 auto; display:block; padding: 0.7em 1.25em; border: 0; background-color: #006dcc; color: #fff; cursor: pointer;'
scoreX.parentNode.insertBefore(button, scoreX.nextSibling)
button.addEventListener('click', function(event) {
video.webkitSetPresentationMode('picture-in-picture');
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment