// ==UserScript== // @name Youtube New UI Fix // @namespace YtNewUIFix // @description Moves the controls under the video and makes the UI look like it was before august 2015 // @author Roy Scheerens // @homepageURL https://greasyfork.org/en/scripts/11485-youtube-new-ui-fix // @include https://www.youtube.com/* // @include https://youtube.googleapis.com/embed/* // @include https://www.youtube-nocookie.com/embed/* // @version 2.1.1 // @grant none // @downloadURL none // ==/UserScript== /* Original typescript code: https://mega.nz/#!gVIDxJgZ!-xXTYG6lNc7aGtW4ITPq0yNe62emBNGdfKg9cB58whs */ var YtNewUIFix = (function () { function YtNewUIFix() { this.isEmbedded = window.top !== window.self; this.addWatchLater = this.getStorage("addWatchLater", true); this.showControlsFullscreen = this.getStorage("showControlsFullscreen", true); this.showControlsNonFullscreen = this.getStorage("showControlsNonFullscreen", true); this.removeAnimations = this.getStorage("removeAnimations", false); this.optionsReversed = this.getStorage("optionsReversed", false); this.progressBigger = this.getStorage("progressBigger", false); this.showTitleOnHover = this.getStorage("showTitleOnHover", false); this.alwaysVolume = this.getStorage("alwaysVolume", false); } YtNewUIFix.prototype.applyFix = function () { var _this = this; if (document.body.innerHTML.length === 0) { // empty page can be ignored (in share tab before it's active) return; } this.addCSS(); if (localStorage) { this.addOptions(); } this.checkMoviePlayer(); window.setInterval(function () { _this.checkMoviePlayer(); }, 1000); }; YtNewUIFix.prototype.getStorage = function (key, defaultVal) { if (!localStorage) { return defaultVal; } var result = localStorage.getItem(key); if (result) { return result === "true"; } else { return defaultVal; } }; YtNewUIFix.timeFormat = function (t) { t = 0 > t ? 0 : Math.round(t); return (3600 <= t ? "" + Math.floor(t / 3600) + ":" + ("0" + Math.floor(t / 60) % 60).slice(-2) : "" + Math.floor(t / 60) % 60) + ":" + ("0" + t % 60).slice(-2); }; YtNewUIFix.prototype.checkMoviePlayer = function () { if (!this.moviePlayer || !this.moviePlayer.parentNode) { this.moviePlayer = document.querySelector("div.html5-video-player"); if (this.moviePlayer && this.moviePlayer.parentNode) { var video = document.querySelector(".html5-main-video"); var playProgress = document.querySelector(".ytp-play-progress"); var loadProgress = document.querySelector(".ytp-load-progress"); var currentTime = document.querySelector(".ytp-time-current"); if (video) { if (playProgress && currentTime) { video.addEventListener("timeupdate", function () { if (video.readyState == 4) { playProgress.style.transform = "scaleX(" + (video.currentTime / video.duration) + ")"; } currentTime.innerText = YtNewUIFix.timeFormat(video.currentTime); }); } if (loadProgress) { video.addEventListener("progress", function () { if (video.readyState == 4) { loadProgress.style.transform = "scaleX(" + (video.buffered.end(video.buffered.length - 1) / video.duration) + ")"; } }); } } } } if (this.moviePlayer) { /*var settings: HTMLDivElement = document.querySelector(".ytp-settings-menu .ytp-panel-menu"); if (settings && !settings.querySelector(".yt-fix-settings")) { var settingsDiv: HTMLDivElement = document.createElement("div"); //