Created
April 30, 2018 19:43
-
-
Save cuylerstuwe/dfee374ff5611e90c101bb37a636328e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // ==UserScript== | |
| // @name YT Embed Control Message Receiver | |
| // @namespace salembeats | |
| // @version 1.2 | |
| // @description Control Embedded YT iFrames with postMessage | |
| // @author Cuyler Stuwe (salembeats) | |
| // @include https://www.youtube.com/embed/* | |
| // @grant none | |
| // ==/UserScript== | |
| function showOverlay() { | |
| let overlayDiv = document.createElement("DIV"); | |
| overlayDiv.style.position = "fixed"; | |
| overlayDiv.style.left = "50%"; | |
| overlayDiv.style.transform = "translateX(-50%)"; | |
| overlayDiv.style.top = "0px"; | |
| overlayDiv.style.zIndex = Number.MAX_SAFE_INTEGER; | |
| overlayDiv.style.backgroundColor = "black"; | |
| overlayDiv.style.color = "white"; | |
| overlayDiv.style.pointerEvents = "none"; | |
| overlayDiv.innerText = "Cuyler's YT Embed Control Message Receiver"; | |
| document.body.insertAdjacentElement('afterend', overlayDiv); | |
| } | |
| function playAtDoubleSpeed() { | |
| let settingsButton = document.querySelector(".ytp-settings-button"); | |
| settingsButton.click(); | |
| document.querySelectorAll(".ytp-menuitem-content").forEach( function(el) { | |
| if( el.textContent.includes("Normal") ) { | |
| el.click(); | |
| return; | |
| } | |
| }); | |
| document.querySelectorAll(".ytp-menuitem-label").forEach( function(el) { | |
| if( el.textContent.includes("2") ) { | |
| el.click(); | |
| return; | |
| } | |
| }); | |
| } | |
| (function main() { | |
| showOverlay(); | |
| playAtDoubleSpeed(); | |
| e = window; | |
| while (e.frameElement !== null) {e = e.parent;} | |
| e.parent.focus(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment