Last active
October 12, 2018 07:46
-
-
Save mashiro/2cd6a30353b27326630b93768136fe62 to your computer and use it in GitHub Desktop.
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
(() => { | |
const togglePIP = (video) => { | |
if (!video.webkitSetPresentationMode) { | |
alert("This browser is not support PIP mode."); | |
return; | |
} | |
video.webkitSetPresentationMode(video.webkitPresentationMode === "picture-in-picture" ? "inline" : "picture-in-picture"); | |
}; | |
const video = document.querySelector("video"); | |
const ul = document.querySelector("ul[class$=Share]"); | |
const li = document.createElement("li"); | |
const button = document.createElement("button"); | |
button.type = "button"; | |
button.style.width = "31px"; | |
button.style.height = "31px"; | |
button.style.backgroundColor = "#888"; | |
button.style.borderRadius = "100%"; | |
button.textContent = "P"; | |
button.addEventListener("click", (e) => togglePIP(video)); | |
li.appendChild(button); | |
ul.insertBefore(li, ul.firstChild); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment