Youtube UI Fix

Moves the controls under the video and makes the UI look like it was before august 2015

  1. // ==UserScript==
  2. // @name Youtube UI Fix
  3. // @namespace YtUIFix
  4. // @description Moves the controls under the video and makes the UI look like it was before august 2015
  5. // @author Roy Scheerens
  6. // @homepageURL https://greatest.deepsurf.us/en/scripts/11485
  7. // @include https://www.youtube.com*
  8. // @include https://youtube.com*
  9. // @include https://youtube.googleapis.com/embed*
  10. // @include https://www.youtube-nocookie.com/embed*
  11. // @version 2.4.16
  12. // @grant none
  13. // @license MIT
  14. // ==/UserScript==
  15. var YtNewUIFix = /** @class */ (function () {
  16. function YtNewUIFix() {
  17. var _this = this;
  18. this.prefix = "ytfix::";
  19. this.isEmbedded = window.top !== window.self;
  20. this.isSettingsPage = window.location.href.toLowerCase().match("(\\.com\\/embed|\\.com)\\/ui_fix_options") !== null;
  21. document.body.classList.add("yt-ui-fix");
  22. this.readOptions();
  23. addEventListener("storage", function (e) {
  24. if (e.key && e.key.indexOf(_this.prefix) >= 0) {
  25. _this.readOptions();
  26. _this.showOptions();
  27. _this.addCSS();
  28. _this.handleWatchLater();
  29. }
  30. });
  31. }
  32. YtNewUIFix.prototype.readOptions = function () {
  33. this.setOption("addWatchLater", true);
  34. this.setOption("showControlsFullscreen", true);
  35. this.setOption("showControlsNonFullscreen", true);
  36. this.setOption("changeColorsFullscreen", true);
  37. this.setOption("changeColorsNonFullscreen", true);
  38. this.setOption("removeAnimations", false);
  39. this.setOption("optionsReversed", false);
  40. this.setOption("progressBigger", false);
  41. this.setOption("alwaysVolume", false);
  42. };
  43. YtNewUIFix.prototype.applyFix = function () {
  44. var _this = this;
  45. if (document.body.innerHTML.length === 0) {
  46. // empty page can be ignored (in share tab before it's active)
  47. return;
  48. }
  49. if (!this.isSettingsPage) {
  50. this.addCSS();
  51. this.checkMoviePlayer();
  52. window.setInterval(function () {
  53. _this.checkMoviePlayer();
  54. _this.handleWatchLater();
  55. }, 1000);
  56. }
  57. this.addOptions();
  58. };
  59. YtNewUIFix.prototype.setOption = function (key, defaultVal) {
  60. if (!localStorage) {
  61. this[key] = defaultVal;
  62. }
  63. var result = this.getSetting(key);
  64. if (result) {
  65. this[key] = (result === "true");
  66. }
  67. else {
  68. this[key] = defaultVal;
  69. }
  70. };
  71. YtNewUIFix.prototype.getSetting = function (key) {
  72. return localStorage.getItem(this.prefix + key);
  73. };
  74. YtNewUIFix.prototype.setSetting = function (key, value) {
  75. localStorage.setItem(this.prefix + key, String(value));
  76. };
  77. YtNewUIFix.prototype.checkMoviePlayer = function () {
  78. if (!this.moviePlayer || !this.moviePlayer.parentNode) {
  79. this.moviePlayer = document.querySelector(".html5-video-player");
  80. }
  81. if (this.moviePlayer && this.moviePlayer.parentNode) {
  82. if (!this.moviePlayer.classList.contains("seeking-mode") &&
  83. !this.moviePlayer.classList.contains("dragging-mode") &&
  84. (this.showControlsNonFullscreen && !this.moviePlayer.classList.contains("ytp-fullscreen") || this.showControlsFullscreen && this.moviePlayer.classList.contains("ytp-fullscreen"))) {
  85. var video = this.moviePlayer.querySelector("video");
  86. var progressBarWidthsCollection_1 = this.moviePlayer.querySelectorAll(".ytp-progress-bar-padding");
  87. if (video && progressBarWidthsCollection_1) {
  88. var totalProgressBarWidth = 0;
  89. for (var i = 0; i < progressBarWidthsCollection_1.length; i++) {
  90. totalProgressBarWidth += progressBarWidthsCollection_1[i].offsetWidth;
  91. }
  92. var durationWidthRatio_1 = video.duration / totalProgressBarWidth;
  93. var updateProgress = function (progressBarChaptersCollection, progress) {
  94. if (progressBarChaptersCollection) {
  95. // loop inside chapters
  96. var chaptersPixelWidthUntilCurrentChapter = 0;
  97. for (var i = 0; i < progressBarWidthsCollection_1.length; i++) {
  98. if (progress > durationWidthRatio_1 * (chaptersPixelWidthUntilCurrentChapter + progressBarWidthsCollection_1[i].offsetWidth)) {
  99. progressBarChaptersCollection[i].style.transform = "scaleX(1)";
  100. chaptersPixelWidthUntilCurrentChapter += progressBarWidthsCollection_1[i].offsetWidth;
  101. }
  102. else {
  103. var currentTimeInChapterInSeconds = progress - (durationWidthRatio_1 * chaptersPixelWidthUntilCurrentChapter);
  104. var currentChapterLengthInSeconds = durationWidthRatio_1 * progressBarWidthsCollection_1[i].offsetWidth;
  105. var currentChapterTimeRatio = currentTimeInChapterInSeconds / currentChapterLengthInSeconds;
  106. progressBarChaptersCollection[i].style.transform = "scaleX(" + currentChapterTimeRatio + ")";
  107. break;
  108. }
  109. }
  110. }
  111. };
  112. var buff = video.buffered;
  113. updateProgress(this.moviePlayer.querySelectorAll(".ytp-play-progress"), video.currentTime);
  114. if (buff.length > 0) {
  115. updateProgress(this.moviePlayer.querySelectorAll(".ytp-load-progress"), buff.end(buff.length - 1));
  116. }
  117. else {
  118. updateProgress(this.moviePlayer.querySelectorAll(".ytp-load-progress"), 0);
  119. }
  120. var currentTime = this.moviePlayer.querySelector(".ytp-time-current");
  121. if (currentTime) {
  122. currentTime.innerText = this.prettifyVideoTime(video);
  123. }
  124. }
  125. }
  126. }
  127. };
  128. YtNewUIFix.prototype.prettifyVideoTime = function (video) {
  129. var seconds = "" + Math.floor(video.currentTime % 60);
  130. var minutes = "" + Math.floor((video.currentTime % 3600) / 60);
  131. var hours = "" + Math.floor(video.currentTime / 3600);
  132. if (video.currentTime / 60 > 60) {
  133. return hours + ":" + minutes.padStart(2, '0') + ":" + seconds.padStart(2, '0');
  134. }
  135. else {
  136. return minutes + ":" + seconds.padStart(2, '0');
  137. }
  138. };
  139. YtNewUIFix.prototype.handleWatchLater = function () {
  140. if (!this.watchLaterbutton || !this.settingsButton) {
  141. this.watchLaterbutton = document.querySelector(".ytp-chrome-top .ytp-watch-later-button");
  142. if (!this.watchLaterbutton)
  143. return;
  144. this.settingsButton = document.querySelector(".ytp-settings-button");
  145. if (this.watchLaterbutton && this.watchLaterbutton.parentElement) {
  146. this.oldWatchParent = this.watchLaterbutton.parentElement;
  147. }
  148. }
  149. if (this.watchLaterbutton && this.settingsButton) {
  150. if (this.addWatchLater && this.settingsButton.parentNode) {
  151. if (this.watchLaterbutton.parentNode !== this.settingsButton.parentNode) {
  152. this.settingsButton.parentNode.insertBefore(this.watchLaterbutton, this.settingsButton);
  153. }
  154. }
  155. else {
  156. this.oldWatchParent.appendChild(this.watchLaterbutton);
  157. }
  158. }
  159. };
  160. YtNewUIFix.prototype.addCSS = function () {
  161. var css = "";
  162. var StyleId = "YoutubeNewUIFix-Style";
  163. css = this.fixColors(css);
  164. css = this.fixControls(css);
  165. css = this.fixBigMode(css);
  166. css = this.addExtras(css);
  167. var style = document.getElementById(StyleId);
  168. if (style && style.parentNode) {
  169. style.parentNode.removeChild(style);
  170. }
  171. style = document.createElement("style");
  172. style.id = StyleId;
  173. style.textContent = css;
  174. document.head.appendChild(style);
  175. };
  176. YtNewUIFix.prototype.fixControls = function (css) {
  177. // options
  178. css += "h3.optionChanged::after { content: 'Refresh page to save changes'; color: red; position: relative; left: 15px; }\n\n";
  179. css += ".account-content-on-player { top: 0px; left: 0px; position: absolute; padding: 0; margin: 0; width: 100%; height: 100% }";
  180. css += ".account-content-on-player account-section { top: 50px; left: 50px; z-index: 100; background-color: white; padding: 10px 25px 30px; margin: 0; }";
  181. css += ".html5-video-player.ytp-fullscreen .html5-video-container { height: 100vh; }";
  182. css += ".html5-video-player:not(.ytp-fullscreen) .html5-video-container { height: 100%; }";
  183. css += ".ytp-chrome-bottom { left: 0 !important; }\n";
  184. css += ".ytp-chrome-controls { margin: 0 -12px; }\n";
  185. css += "body:not(.ytwp-window-player) #page:not(.watch-stage-mode) #watch7-sidebar { transform: translateY(-35px); }\n";
  186. css += "body:not(.ytwp-window-player) #page.watch-stage-mode #watch-appbar-playlist { margin-top: 35px; }\n";
  187. css += ".html5-main-video { top: 0!important; }\n";
  188. // move content below video down in the material layout
  189. css += "ytd-watch-flexy[theater] #columns { margin-top: 35px!important; }";
  190. css += "ytd-watch-flexy:not([theater]) #below { margin-top: 35px!important; }";
  191. // remove stupid border rounding
  192. css += "ytd-player { overflow: visible!important; border-radius: 0!important; }";
  193. // width correction of the controls in the material layout
  194. css += ".html5-main-video { max-width: 100%; }";
  195. if (this.isEmbedded) {
  196. css += ".ytp-watch-later-button { transform: translateY(-3.5px); }";
  197. css += ".html5-main-video { object-fit: contain!important; }";
  198. }
  199. else {
  200. css += "ytd-watch-flexy[theater] .html5-main-video { object-fit: contain!important; }";
  201. }
  202. css += ".ytp-chrome-bottom { max-width: calc(100% - 24px); width: calc(100% - 24px); }";
  203. // progressbar
  204. css += ".ytp-progress-bar-container:not(.ytp-pulling) { height: 5px!important; bottom: 30px!important; }\n";
  205. css += ".ytp-progress-list { transform-origin: center top; }\n\n";
  206. css += ".ytp-big-mode .ytp-progress-list { transform: scaleY(0.6); }\n\n";
  207. // scale down
  208. css += ".ytp-chrome-bottom { height: 35px!important; padding: 0!important; }\n";
  209. css += ".ytp-chrome-controls .ytp-button:not(.ytp-chapter-title):not(.ytp-watch-later-button) { width: 33px!important; }\n";
  210. css += ".ytp-chrome-controls .ytp-watch-later-icon { width: 24px!important; height: 24px!important; }\n";
  211. css += ".ytp-chrome-controls .ytp-watch-later-button { opacity: 1!important; width: 24px!important; display: inline-block!important; }\n";
  212. css += ".ytp-left-controls { margin-left: 5px }\n";
  213. css += ".ytp-time-display { height: 31px; line-height: 32px!important; font-size: 12px!important; }\n";
  214. css += ".ytp-left-controls, .ytp-right-controls { height: 32px!important; margin-top: 3px; line-height: 36px; }\n\n";
  215. // badges
  216. css += ".ytp-settings-button.ytp-hd-quality-badge::after,.ytp-settings-button.ytp-4k-quality-badge::after,.ytp-settings-button.ytp-5k-quality-badge::after,.ytp-settings-button.ytp-8k-quality-badge::after { content:''!important; top:6px!important; right:4px!important; height:9px!important; width:13px!important; padding: 0!important; }\n";
  217. css += ".ytp-settings-button.ytp-hd-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIw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W9wYWNpdHk9IjAuNjQ3MSIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjxwYXRoIGQ9Ik0xMSw1IEwxMSw3IEwxMCw3IEwxMCw2IEwxMCw1IEwxMSw1IE0xMCw1IEw4LDUgTDgsNiBMOCw3IEw3LDcgTDcsMiBMOCwyIEw4LDQgTDEwLDQgTDEwLDUgTTEwLDIgTDExLDIgTDExLDQgTDEwLDQgTDEwLDIgTTMsNiBMNSw2IEw1LDcgTDMsNyBNMywyIEw1LDIgTDUsMyBMMywzIEwzLDIgWiBNNSw1IEw2LDUgTDYsNiBMNSw2IEw1LDUgWiBNMyw0IEw1LDQgTDUsNSBMMyw1IEwzLDQgWiBNNSwzIEw2LDMgTDYsNCBMNSw0IEw1LDMgWiBNMiw1IEwzLDUgTDMsNiBMMiw2IEwyLDUgWiBNMiwzIEwzLDMgTDMsNCBMMiw0IEwyLDMgWiIgZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjwvc3ZnPg==)!important; }";
  221. css += ".ytp-settings-button.ytp-3d-badge-grey:after,.ytp-settings-button.ytp-3d-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik0yIDJoNHY1aC00di0xaDN2LTFoLTN2LTFoM3YtMWgtM3pNNyAyaDN2MWgtMnYzaDJ2MWgtM3pNMTAgM2gxdjNoLTF6IiBmaWxsPSIjZmZmIiAvPjxwYXRoIGQ9Ik0yIDNoM3YxaC0zek04IDNoMnYxaC0yek0yIDVoM3YxaC0zek0xMCA2aDF2MWgtMXpNMiA3aDR2MWgtNHpNNyA3aDN2MWgtM3oiIGZpbGw9IiMwMDAiIGZpbGwtb3BhY2l0eT0iMC42NDcxIiAvPjwvc3ZnPg==)!important; }";
  222. css += ".ytp-color-white .ytp-settings-button.ytp-hd-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik01LDcgTDUsNiBMNSw1IEwzLDUgTDMsNiBMMyw3IEwyLDcgTDIsMiBMMywyIEwzLDQgTDUsNCBMNSwyIEw2LDIgTDYsNyBMNSw3IFogTTExLDYgTDEwLDYgTDEwLDcgTDcsNyBMNywyIEwxMCwyIEwxMCwzIEwxMSwzIEwxMSw2IFogTTEwLDQgTDEwLDMgTDgsMyBMOCw0IEw4LDYgTDEwLDYgTDEwLDQgWiIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjwvc3ZnPg==)!important; }";
  223. css += ".ytp-color-white .ytp-settings-button.ytp-4k-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik0xMSw1IEwxMSw3IEwxMCw3IEwxMCw2IEwxMCw1IEwxMSw1IFogTTEwLDUgTDgsNSBMOCw2IEw4LDcgTDcsNyBMNywyIEw4LDIgTDgsNCBMMTAsNCBMMTAsNSBaIE00LDQgTDMsNCBMMyw1IEw0LDUgTDQsNCBaIE00LDcgTDQsNiBMMiw2IEwyLDQgTDMsNCBMMywzIEw0LDMgTDQsMiBMNSwyIEw1LDUgTDYsNSBMNiw2IEw1LDYgTDUsNyBMNCw3IFogTTEwLDIgTDExLDIgTDExLDQgTDEwLDQgTDEwLDIgWiIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjwvc3ZnPg==)!important; }";
  224. css += ".ytp-color-white .ytp-settings-button.ytp-5k-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik0xMSw1IEwxMSw3IEwxMCw3IEwxMCw2IEwxMCw1IEwxMSw1IE0xMCw1IEw4LDUgTDgsNiBMOCw3IEw3LDcgTDcsMiBMOCwyIEw4LDQgTDEwLDQgTDEwLDUgTTEwLDIgTDExLDIgTDExLDQgTDEwLDQgTDEwLDIgTTIsNiBMNSw2IEw1LDcgTDIsNyBNNSw1IEw2LDUgTDYsNiBMNSw2IE01LDQgTDMsNCBMMywzIEw2LDMgTDYsMiBMMiwyIEwyLDUgTDUsNSBMNSw0IFoiIGZpbGwtcnVsZT0iZXZlbm9kZCIgLz48L3N2Zz4=)!important; }";
  225. css += ".ytp-color-white .ytp-settings-button.ytp-8k-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik0xMSw1IEwxMSw3IEwxMCw3IEwxMCw2IEwxMCw1IEwxMSw1IE0xMCw1IEw4LDUgTDgsNiBMOCw3IEw3LDcgTDcsMiBMOCwyIEw4LDQgTDEwLDQgTDEwLDUgTTEwLDIgTDExLDIgTDExLDQgTDEwLDQgTDEwLDIgTTMsNiBMNSw2IEw1LDcgTDMsNyBNMywyIEw1LDIgTDUsMyBMMywzIEwzLDIgWiBNNSw1IEw2LDUgTDYsNiBMNSw2IEw1LDUgWiBNMyw0IEw1LDQgTDUsNSBMMyw1IEwzLDQgWiBNNSwzIEw2LDMgTDYsNCBMNSw0IEw1LDMgWiBNMiw1IEwzLDUgTDMsNiBMMiw2IEwyLDUgWiBNMiwzIEwzLDMgTDMsNCBMMiw0IEwyLDMgWiIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjwvc3ZnPg==)!important; }";
  226. css += ".ytp-color-white .ytp-settings-button.ytp-3d-badge-grey:after,.ytp-color-white .ytp-settings-button.ytp-3d-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik0yIDJoNHY1aC00di0xaDN2LTFoLTN2LTFoM3YtMWgtM3pNNyAyaDN2MWgtMnYzaDJ2MWgtM3pNMTAgM2gxdjNoLTF6IiBmaWxsPSIjMDAwIiAvPjwvc3ZnPg==)!important; }";
  227. // closed captions (line under the button, and position of captions)
  228. css += ".ytp-chrome-controls .ytp-button[aria-pressed='true']::after { width: 18px; left: 8px; }\n";
  229. css += ".caption-window.ytp-caption-window-bottom { margin-bottom:40px!important }\n";
  230. css += ".ytp-player-content { top: 48px !important; bottom: 49px !important; }\n";
  231. // fix watch later messing up embedded
  232. css += ".ytp-chrome-bottom .ytp-watch-later-title { display: none; }\n";
  233. if (this.isEmbedded && this.addWatchLater) {
  234. css += ".ytp-watch-later-button { margin: 0!important; }\n";
  235. }
  236. return css;
  237. };
  238. YtNewUIFix.prototype.fixBigMode = function (css) {
  239. /* big mode: smaller scrubber */
  240. css += ".ytp-big-mode .ytp-scrubber-button { height: 13px!important; width: 13px!important; border-radius: 6.5px!important; }\n";
  241. css += ".ytp-big-mode .ytp-scrubber-container { top: -4px; left: -6.5px; }\n\n";
  242. /* big mode: 24px edges instead of 12px */
  243. css += ".ytp-big-mode .ytp-left-controls { margin-left: -7px }\n";
  244. css += ".ytp-big-mode .ytp-fullscreen-button { margin-right: -7px }\n\n";
  245. /* big mode: smaller volume slider */
  246. css += ".ytp-big-mode .ytp-volume-slider-handle { width: 12px; height: 12px; border-radius: 6px; margin-top: -6px; }\n";
  247. css += ".ytp-big-mode .ytp-volume-slider-active .ytp-volume-panel { width: 72px; }\n\n";
  248. /* big mode: smaller auto nav */
  249. css += ".ytp-big-mode .ytp-autonav-toggle-button { height: 14.4px!important; width: 36px!important; border-radius: 14.4px!important; }\n";
  250. css += ".ytp-big-mode .ytp-autonav-toggle-button::after { height: 20.4px!important; width: 20.4px!important; border-radius: 20.4px!important; margin-top: -3px!important; }\n\n";
  251. /* padding around volume should be 0 2 */
  252. css += ".ytp-button.ytp-mute-button { padding: 0 2px!important; }\n\n";
  253. return css;
  254. };
  255. YtNewUIFix.prototype.fixColors = function (css) {
  256. if (this.changeColorsNonFullscreen) {
  257. css += ".html5-video-player:not(.ytp-big-mode) .ytp-chrome-bottom { background-color: #1B1B1B; border-left: 12px solid #1B1B1B; border-right: 12px solid #1B1B1B; }\n";
  258. css += ".html5-video-player:not(.ytp-big-mode) .ytp-gradient-bottom { display: none!important; }\n";
  259. css += ".html5-video-player:not(.ytp-big-mode) .ytp-chrome-controls svg path { fill: #8E8E8E }\n";
  260. }
  261. else {
  262. css += ".html5-video-player:not(.ytp-big-mode) .ytp-chrome-bottom { border-left: 12px solid transparent; border-right: 12px solid transparent; }\n";
  263. if (this.showControlsNonFullscreen) {
  264. css += ".html5-video-player:not(.ytp-fullscreen) .ytp-gradient-bottom { display: none!important; }\n";
  265. }
  266. }
  267. if (this.changeColorsFullscreen) {
  268. css += ".ytp-big-mode .ytp-chrome-bottom { background-color: #1B1B1B; border-left: 24px solid #1B1B1B; border-right: 24px solid #1B1B1B; }\n";
  269. css += ".ytp-big-mode .ytp-gradient-bottom { display: none!important; }\n";
  270. css += ".ytp-big-mode .ytp-chrome-controls svg path { fill: #8E8E8E }\n";
  271. }
  272. else {
  273. css += ".ytp-big-mode .ytp-chrome-bottom { border-left: 24px solid transparent; border-right: 24px solid transparent; }\n";
  274. if (this.showControlsFullscreen) {
  275. css += ".html5-video-player.ytp-fullscreen .ytp-gradient-bottom { display: none!important; }\n";
  276. }
  277. }
  278. css += ".ytp-gradient-top { display: none!important; }\n";
  279. css += "\n";
  280. return css;
  281. };
  282. YtNewUIFix.prototype.addExtras = function (css) {
  283. if (this.showControlsFullscreen) {
  284. css += "html:not(.floater):not(.iri-always-visible) .html5-video-player.ytp-fullscreen:not(.ytp-hide-controls) .html5-main-video { height: calc(100% - 35px)!important; min-height: calc(100% - 35px) !important; max-height: calc(100% - 35px) !important; }\n";
  285. css += ".html5-video-player.ytp-fullscreen:not(.ytp-hide-controls) .ytp-chrome-bottom { opacity: 1!important; display: block!important; }\n";
  286. }
  287. if (this.showControlsNonFullscreen) {
  288. css += "html:not(.floater):not(.iri-always-visible) .html5-video-player:not(.ytp-fullscreen):not(.ytp-hide-controls) .html5-main-video { height: calc(100% - 35px)!important; min-height: calc(100% - 35px) !important; max-height: calc(100% - 35px) !important; }\n";
  289. css += ".html5-video-player:not(.ytp-fullscreen):not(.ytp-hide-controls) .ytp-chrome-bottom { opacity: 1!important; display: block!important; }\n";
  290. if (!this.isEmbedded) {
  291. css += "html:not(.floater):not(.iri-always-visible):not(.part_fullbrowser) #movie_player:not(.ytp-fullscreen):not(.ytp-hide-controls) { height: calc(100% + 35px)!important; }\n";
  292. }
  293. css += "html.floater .html5-video-player, html.iri-always-visible .html5-video-player { padding-bottom: 35px; }\n";
  294. css += "#theater-background { padding-bottom: 35px; }\n\n";
  295. css += "#placeholder-player { padding-bottom: 35px; }\n";
  296. }
  297. if (!this.showControlsFullscreen && !this.showControlsNonFullscreen) {
  298. css += ".html5-video-player .html5-main-video { height: 100%!important; }\n";
  299. }
  300. if (this.removeAnimations) {
  301. css += ".ytp-bezel { display: none!important; }\n";
  302. css += ".html5-endscreen *, .html5-video-player div { transition-property: none !important; animation: none !important; }\n";
  303. }
  304. if (this.optionsReversed) {
  305. css += ".ytp-panel { display: -webkit-flex; -webkit-flex-direction: column; display: flex; flex-direction: column; }\n";
  306. css += ".ytp-panel-header { order: 2; border-top: 1px solid #444; border-bottom: none; }\n";
  307. css += ".ytp-panel-content { order: 1; }\n";
  308. }
  309. if (this.alwaysVolume) {
  310. /* Have the volume slider always be visible */
  311. css += ".ytp-volume-panel { width: 52px; margin-right: 3px; } .ytp-big-mode .ytp-volume-panel { width: 78px; }";
  312. }
  313. if (this.progressBigger) {
  314. /* Make the progressbar fill up the entire space when not hovering over (thanks to Takato) */
  315. css += " .ytp-progress-bar-container:not(:hover):not(.ytp-pulling) .ytp-chapter-hover-container:not(.ytp-exp-chapter-hover-container) .ytp-progress-list { width: calc(100% + 24px); left: -12px; }";
  316. css += ".ytp-big-mode .ytp-progress-bar-container:not(:hover):not(.ytp-pulling) .ytp-chapter-hover-container:not(.ytp-exp-chapter-hover-container) .ytp-progress-list { width: calc(100% + 48px); left: -24px; }";
  317. }
  318. return css;
  319. };
  320. YtNewUIFix.prototype.showOptions = function () {
  321. var options = document.querySelectorAll("#YoutubeNewUIFix-Options input");
  322. if (options.length > 0) {
  323. for (var i = 0; i < options.length; i++) {
  324. options[i].checked = (this.getSetting(options[i].name) === "true");
  325. }
  326. }
  327. };
  328. YtNewUIFix.prototype.addOptions = function () {
  329. var _this = this;
  330. if (localStorage) {
  331. var accSection_1 = document.createElement("div");
  332. accSection_1.id = "YoutubeNewUIFix-Options";
  333. accSection_1.classList.add("account-section");
  334. var header = document.createElement("h3");
  335. header.classList.add("account-section-header");
  336. header.textContent = "Youtube UI Fix Options";
  337. accSection_1.appendChild(header);
  338. {
  339. accSection_1.appendChild(this.createOption("addWatchLater", "Add the watch later button to the controls"));
  340. accSection_1.appendChild(this.createOption("changeColorsNonFullscreen", "Change the colors back to their original gray (in non-full-screen mode)"));
  341. accSection_1.appendChild(this.createOption("changeColorsFullscreen", "Change the colors back to their original gray in full-screen mode"));
  342. accSection_1.appendChild(this.createOption("showControlsNonFullscreen", "Always show the controls (in non-full-screen mode)"));
  343. accSection_1.appendChild(this.createOption("showControlsFullscreen", "Always show the controls in full-screen mode"));
  344. accSection_1.appendChild(this.createOption("removeAnimations", "Remove all animations"));
  345. accSection_1.appendChild(this.createOption("optionsReversed", "Move the 'go back' button in the settings menus to the bottom"));
  346. accSection_1.appendChild(this.createOption("progressBigger", "Make the progressbar take up the whole width (but not when hovering over)"));
  347. accSection_1.appendChild(this.createOption("alwaysVolume", "Have the volume slider be always visible"));
  348. }
  349. var content = document.querySelector(".account-content");
  350. var footer = document.querySelector(".account-footer");
  351. var selectedItem = document.querySelector(".creator-sidebar-item.selected");
  352. if (!content) {
  353. content = document.querySelector("#contents");
  354. if (!content) {
  355. return;
  356. }
  357. }
  358. if (!selectedItem) {
  359. selectedItem = document.querySelector(".ytd-settings-sidebar-renderer[active]");
  360. }
  361. if (this.isSettingsPage) {
  362. document.head.innerHTML = document.body.innerHTML = "";
  363. document.body.appendChild(accSection_1);
  364. }
  365. else if (content && selectedItem.innerHTML.indexOf("Playback") >= 0) {
  366. if (footer) {
  367. content.insertBefore(accSection_1, footer);
  368. }
  369. else {
  370. content.appendChild(accSection_1);
  371. }
  372. }
  373. var exportBtn_1 = document.createElement("button");
  374. exportBtn_1.classList.add("yt-uix-button", "yt-uix-button-size-default", "yt-uix-button-primary", "account-action-button");
  375. exportBtn_1.type = "button";
  376. exportBtn_1.textContent = "Export Settings";
  377. exportBtn_1.onclick = function () {
  378. var settingsScript = "// ==UserScript==\n";
  379. settingsScript += "// @name Youtube UI Fix Settings\n";
  380. settingsScript += "// @namespace YtUIFix\n";
  381. settingsScript += "// @description Sets the settings for Youtube UI Fix\n";
  382. settingsScript += "// @author Roy Scheerens\n";
  383. settingsScript += "// @homepageURL https://greatest.deepsurf.us/en/scripts/11485\n";
  384. settingsScript += "// @include https://www.youtube.com*\n";
  385. settingsScript += "// @include https://youtube.googleapis.com/embed*\n";
  386. settingsScript += "// @include https://www.youtube-nocookie.com/embed*\n";
  387. settingsScript += "// @version 0.0.1\n";
  388. settingsScript += "// @grant none\n";
  389. settingsScript += "// ==/UserScript==\n";
  390. settingsScript += "\n";
  391. settingsScript += "localStorage.setItem('ytfix::addWatchLater', String(" + String(_this["addWatchLater"]) + "));\n";
  392. settingsScript += "localStorage.setItem('ytfix::showControlsFullscreen', String(" + String(_this["showControlsFullscreen"]) + "));\n";
  393. settingsScript += "localStorage.setItem('ytfix::showControlsNonFullscreen', String(" + String(_this["showControlsNonFullscreen"]) + "));\n";
  394. settingsScript += "localStorage.setItem('ytfix::changeColorsFullscreen', String(" + String(_this["changeColorsFullscreen"]) + "));\n";
  395. settingsScript += "localStorage.setItem('ytfix::changeColorsNonFullscreen', String(" + String(_this["changeColorsNonFullscreen"]) + "));\n";
  396. settingsScript += "localStorage.setItem('ytfix::removeAnimations', String(" + String(_this["removeAnimations"]) + "));\n";
  397. settingsScript += "localStorage.setItem('ytfix::optionsReversed', String(" + String(_this["optionsReversed"]) + "));\n";
  398. settingsScript += "localStorage.setItem('ytfix::progressBigger', String(" + String(_this["progressBigger"]) + "));\n";
  399. settingsScript += "localStorage.setItem('ytfix::alwaysVolume', String(" + String(_this["alwaysVolume"]) + "));\n";
  400. var hiddenText = accSection_1.getElementsByTagName("textarea")[0] || document.createElement("textarea");
  401. hiddenText.textContent = settingsScript;
  402. accSection_1.appendChild(hiddenText);
  403. hiddenText.select();
  404. document.execCommand("cut");
  405. accSection_1.removeChild(hiddenText);
  406. exportBtn_1.innerHTML = "Settings Userscipt Copied";
  407. };
  408. if (footer) {
  409. footer.appendChild(exportBtn_1);
  410. }
  411. else {
  412. content.appendChild(exportBtn_1);
  413. }
  414. }
  415. };
  416. YtNewUIFix.prototype.createOption = function (name, description) {
  417. var _this = this;
  418. var accDiv = document.createElement("div");
  419. accDiv.classList.add("account-section-setting");
  420. accDiv.innerHTML = "\n\t\t <label style=\"font-size: 13px\">\n\t\t\t <span class='yt-uix-form-input-checkbox-container " + (this[name] ? "checked" : "") + "'>\n <input class='yt-uix-form-input-checkbox' name='" + name + "' " + (this[name] ? "checked='checked'" : "") + " type='checkbox'>\n <span class='yt-uix-form-input-checkbox-element'></span>\n </span>\n\t\t\t " + description + "\n\t\t </label>";
  421. var accInput = accDiv.querySelector("input[name='" + name + "']");
  422. accInput.onclick = function () {
  423. _this.setSetting(name, accInput.checked);
  424. _this[name] = accInput.checked;
  425. };
  426. return accDiv;
  427. };
  428. return YtNewUIFix;
  429. }());
  430. new YtNewUIFix().applyFix();