Youtube UI Fix

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

当前为 2023-09-26 提交的版本,查看 最新版本

  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://greasyfork.org/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.15
  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. updateProgress(this.moviePlayer.querySelectorAll(".ytp-play-progress"), video.currentTime);
  113. updateProgress(this.moviePlayer.querySelectorAll(".ytp-load-progress"), video.buffered.end(video.buffered.length - 1));
  114. var currentTime = this.moviePlayer.querySelector(".ytp-time-current");
  115. if (currentTime) {
  116. currentTime.innerText = this.prettifyVideoTime(video);
  117. }
  118. }
  119. }
  120. }
  121. };
  122. YtNewUIFix.prototype.prettifyVideoTime = function (video) {
  123. var seconds = "" + Math.floor(video.currentTime % 60);
  124. var minutes = "" + Math.floor((video.currentTime % 3600) / 60);
  125. var hours = "" + Math.floor(video.currentTime / 3600);
  126. if (video.currentTime / 60 > 60) {
  127. return hours + ":" + minutes.padStart(2, '0') + ":" + seconds.padStart(2, '0');
  128. }
  129. else {
  130. return minutes + ":" + seconds.padStart(2, '0');
  131. }
  132. };
  133. YtNewUIFix.prototype.handleWatchLater = function () {
  134. if (!this.watchLaterbutton || !this.settingsButton) {
  135. this.watchLaterbutton = document.querySelector(".ytp-chrome-top .ytp-watch-later-button");
  136. if (!this.watchLaterbutton)
  137. return;
  138. this.settingsButton = document.querySelector(".ytp-settings-button");
  139. if (this.watchLaterbutton && this.watchLaterbutton.parentElement) {
  140. this.oldWatchParent = this.watchLaterbutton.parentElement;
  141. }
  142. }
  143. if (this.watchLaterbutton && this.settingsButton) {
  144. if (this.addWatchLater && this.settingsButton.parentNode) {
  145. if (this.watchLaterbutton.parentNode !== this.settingsButton.parentNode) {
  146. this.settingsButton.parentNode.insertBefore(this.watchLaterbutton, this.settingsButton);
  147. }
  148. }
  149. else {
  150. this.oldWatchParent.appendChild(this.watchLaterbutton);
  151. }
  152. }
  153. };
  154. YtNewUIFix.prototype.addCSS = function () {
  155. var css = "";
  156. var StyleId = "YoutubeNewUIFix-Style";
  157. css = this.fixColors(css);
  158. css = this.fixControls(css);
  159. css = this.fixBigMode(css);
  160. css = this.addExtras(css);
  161. var style = document.getElementById(StyleId);
  162. if (style && style.parentNode) {
  163. style.parentNode.removeChild(style);
  164. }
  165. style = document.createElement("style");
  166. style.id = StyleId;
  167. style.textContent = css;
  168. document.head.appendChild(style);
  169. };
  170. YtNewUIFix.prototype.fixControls = function (css) {
  171. // options
  172. css += "h3.optionChanged::after { content: 'Refresh page to save changes'; color: red; position: relative; left: 15px; }\n\n";
  173. css += ".account-content-on-player { top: 0px; left: 0px; position: absolute; padding: 0; margin: 0; width: 100%; height: 100% }";
  174. css += ".account-content-on-player account-section { top: 50px; left: 50px; z-index: 100; background-color: white; padding: 10px 25px 30px; margin: 0; }";
  175. css += ".html5-video-player.ytp-fullscreen .html5-video-container { height: 100vh; }";
  176. css += ".html5-video-player:not(.ytp-fullscreen) .html5-video-container { height: 100%; }";
  177. css += ".ytp-chrome-bottom { left: 0 !important; }\n";
  178. css += ".ytp-chrome-controls { margin: 0 -12px; }\n";
  179. css += "body:not(.ytwp-window-player) #page:not(.watch-stage-mode) #watch7-sidebar { transform: translateY(-35px); }\n";
  180. css += "body:not(.ytwp-window-player) #page.watch-stage-mode #watch-appbar-playlist { margin-top: 35px; }\n";
  181. css += ".html5-main-video { top: 0!important; }\n";
  182. // move content below video down in the material layout
  183. css += "ytd-watch-flexy[theater] #columns { margin-top: 35px!important; }";
  184. css += "ytd-watch-flexy:not([theater]) #below { margin-top: 35px!important; }";
  185. // remove stupid border rounding
  186. css += "ytd-player { overflow: visible!important; border-radius: 0!important; }";
  187. // width correction of the controls in the material layout
  188. css += ".html5-main-video { max-width: 100%; }";
  189. css += "ytd-watch-flexy[theater] .html5-main-video { object-fit: contain!important; }";
  190. css += ".ytp-chrome-bottom { max-width: calc(100% - 24px); width: calc(100% - 24px); }";
  191. // progressbar
  192. css += ".ytp-progress-bar-container:not(.ytp-pulling) { height: 5px!important; bottom: 30px!important; }\n";
  193. css += ".ytp-progress-list { transform-origin: center top; }\n\n";
  194. css += ".ytp-big-mode .ytp-progress-list { transform: scaleY(0.6); }\n\n";
  195. // scale down
  196. css += ".ytp-chrome-bottom { height: 35px!important; padding: 0!important; }\n";
  197. css += ".ytp-chrome-controls .ytp-button:not(.ytp-chapter-title):not(.ytp-watch-later-button) { width: 33px!important; }\n";
  198. css += ".ytp-chrome-controls .ytp-watch-later-icon { width: 24px!important; height: 24px!important; }\n";
  199. css += ".ytp-chrome-controls .ytp-watch-later-button { opacity: 1!important; width: 24px!important; display: inline-block!important; }\n";
  200. css += ".ytp-left-controls { margin-left: 5px }\n";
  201. css += ".ytp-time-display { height: 31px; line-height: 32px!important; font-size: 12px!important; }\n";
  202. css += ".ytp-left-controls, .ytp-right-controls { height: 32px!important; margin-top: 3px; line-height: 36px; }\n\n";
  203. // badges
  204. 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";
  205. css += ".ytp-settings-button.ytp-hd-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik01LDcgTDYsNyBMNiw4IEw1LDggTDUsNyBaIE0xMCwzIEwxMCw0IEw4LDQgTDgsMyBMMTAsMyBaIE0zLDYgTDMsNSBMNSw1IEw1LDYgTDMsNiBa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MiBMOCwyIEw4LDQgTDEwLDQgTDEwLDUgTTEwLDIgTDExLDIgTDExLDQgTDEwLDQgTDEwLDIgTTMsNiBMNSw2IEw1LDcgTDMsNyBNMywyIEw1LDIgTDUsMyBMMywzIEwzLDIgWiBNNSw1IEw2LDUgTDYsNiBMNSw2IEw1LDUgWiBNMyw0IEw1LDQgTDUsNSBMMyw1IEwzLDQgWiBNNSwzIEw2LDMgTDYsNCBMNSw0IEw1LDMgWiBNMiw1IEwzLDUgTDMsNiBMMiw2IEwyLDUgWiBNMiwzIEwzLDMgTDMsNCBMMiw0IEwyLDMgWiIgZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjwvc3ZnPg==)!important; }";
  209. 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; }";
  210. css += ".ytp-color-white .ytp-settings-button.ytp-hd-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik01LDcgTDUsNiBMNSw1IEwzLDUgTDMsNiBMMyw3IEwyLDcgTDIsMiBMMywyIEwzLDQgTDUsNCBMNSwyIEw2LDIgTDYsNyBMNSw3IFogTTExLDYgTDEwLDYgTDEwLDcgTDcsNyBMNywyIEwxMCwyIEwxMCwzIEwxMSwzIEwxMSw2IFogTTEwLDQgTDEwLDMgTDgsMyBMOCw0IEw4LDYgTDEwLDYgTDEwLDQgWiIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjwvc3ZnPg==)!important; }";
  211. css += ".ytp-color-white .ytp-settings-button.ytp-4k-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik0xMSw1IEwxMSw3IEwxMCw3IEwxMCw2IEwxMCw1IEwxMSw1IFogTTEwLDUgTDgsNSBMOCw2IEw4LDcgTDcsNyBMNywyIEw4LDIgTDgsNCBMMTAsNCBMMTAsNSBaIE00LDQgTDMsNCBMMyw1IEw0LDUgTDQsNCBaIE00LDcgTDQsNiBMMiw2IEwyLDQgTDMsNCBMMywzIEw0LDMgTDQsMiBMNSwyIEw1LDUgTDYsNSBMNiw2IEw1LDYgTDUsNyBMNCw3IFogTTEwLDIgTDExLDIgTDExLDQgTDEwLDQgTDEwLDIgWiIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjwvc3ZnPg==)!important; }";
  212. css += ".ytp-color-white .ytp-settings-button.ytp-5k-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik0xMSw1IEwxMSw3IEwxMCw3IEwxMCw2IEwxMCw1IEwxMSw1IE0xMCw1IEw4LDUgTDgsNiBMOCw3IEw3LDcgTDcsMiBMOCwyIEw4LDQgTDEwLDQgTDEwLDUgTTEwLDIgTDExLDIgTDExLDQgTDEwLDQgTDEwLDIgTTIsNiBMNSw2IEw1LDcgTDIsNyBNNSw1IEw2LDUgTDYsNiBMNSw2IE01LDQgTDMsNCBMMywzIEw2LDMgTDYsMiBMMiwyIEwyLDUgTDUsNSBMNSw0IFoiIGZpbGwtcnVsZT0iZXZlbm9kZCIgLz48L3N2Zz4=)!important; }";
  213. css += ".ytp-color-white .ytp-settings-button.ytp-8k-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik0xMSw1IEwxMSw3IEwxMCw3IEwxMCw2IEwxMCw1IEwxMSw1IE0xMCw1IEw4LDUgTDgsNiBMOCw3IEw3LDcgTDcsMiBMOCwyIEw4LDQgTDEwLDQgTDEwLDUgTTEwLDIgTDExLDIgTDExLDQgTDEwLDQgTDEwLDIgTTMsNiBMNSw2IEw1LDcgTDMsNyBNMywyIEw1LDIgTDUsMyBMMywzIEwzLDIgWiBNNSw1IEw2LDUgTDYsNiBMNSw2IEw1LDUgWiBNMyw0IEw1LDQgTDUsNSBMMyw1IEwzLDQgWiBNNSwzIEw2LDMgTDYsNCBMNSw0IEw1LDMgWiBNMiw1IEwzLDUgTDMsNiBMMiw2IEwyLDUgWiBNMiwzIEwzLDMgTDMsNCBMMiw0IEwyLDMgWiIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjwvc3ZnPg==)!important; }";
  214. 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; }";
  215. // closed captions (line under the button, and position of captions)
  216. css += ".ytp-chrome-controls .ytp-button[aria-pressed='true']::after { width: 18px; left: 8px; }\n";
  217. css += ".caption-window.ytp-caption-window-bottom { margin-bottom:40px!important }\n";
  218. css += ".ytp-player-content { top: 48px !important; bottom: 49px !important; }\n";
  219. // fix watch later messing up embedded
  220. css += ".ytp-chrome-bottom .ytp-watch-later-title { display: none; }\n";
  221. if (this.isEmbedded && this.addWatchLater) {
  222. css += ".ytp-watch-later-button { margin: 0!important; }\n";
  223. }
  224. return css;
  225. };
  226. YtNewUIFix.prototype.fixBigMode = function (css) {
  227. /* big mode: smaller scrubber */
  228. css += ".ytp-big-mode .ytp-scrubber-button { height: 13px!important; width: 13px!important; border-radius: 6.5px!important; }\n";
  229. css += ".ytp-big-mode .ytp-scrubber-container { top: -4px; left: -6.5px; }\n\n";
  230. /* big mode: 24px edges instead of 12px */
  231. css += ".ytp-big-mode .ytp-left-controls { margin-left: -7px }\n";
  232. css += ".ytp-big-mode .ytp-fullscreen-button { margin-right: -7px }\n\n";
  233. /* big mode: smaller volume slider */
  234. css += ".ytp-big-mode .ytp-volume-slider-handle { width: 12px; height: 12px; border-radius: 6px; margin-top: -6px; }\n";
  235. css += ".ytp-big-mode .ytp-volume-slider-active .ytp-volume-panel { width: 72px; }\n\n";
  236. /* big mode: smaller auto nav */
  237. css += ".ytp-big-mode .ytp-autonav-toggle-button { height: 14.4px!important; width: 36px!important; border-radius: 14.4px!important; }\n";
  238. 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";
  239. /* padding around volume should be 0 2 */
  240. css += ".ytp-button.ytp-mute-button { padding: 0 2px!important; }\n\n";
  241. return css;
  242. };
  243. YtNewUIFix.prototype.fixColors = function (css) {
  244. if (this.changeColorsNonFullscreen) {
  245. 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";
  246. css += ".html5-video-player:not(.ytp-big-mode) .ytp-gradient-bottom { display: none!important; }\n";
  247. css += ".html5-video-player:not(.ytp-big-mode) .ytp-chrome-controls svg path { fill: #8E8E8E }\n";
  248. }
  249. else {
  250. css += ".html5-video-player:not(.ytp-big-mode) .ytp-chrome-bottom { border-left: 12px solid transparent; border-right: 12px solid transparent; }\n";
  251. if (this.showControlsNonFullscreen) {
  252. css += ".html5-video-player:not(.ytp-fullscreen) .ytp-gradient-bottom { display: none!important; }\n";
  253. }
  254. }
  255. if (this.changeColorsFullscreen) {
  256. css += ".ytp-big-mode .ytp-chrome-bottom { background-color: #1B1B1B; border-left: 24px solid #1B1B1B; border-right: 24px solid #1B1B1B; }\n";
  257. css += ".ytp-big-mode .ytp-gradient-bottom { display: none!important; }\n";
  258. css += ".ytp-big-mode .ytp-chrome-controls svg path { fill: #8E8E8E }\n";
  259. }
  260. else {
  261. css += ".ytp-big-mode .ytp-chrome-bottom { border-left: 24px solid transparent; border-right: 24px solid transparent; }\n";
  262. if (this.showControlsFullscreen) {
  263. css += ".html5-video-player.ytp-fullscreen .ytp-gradient-bottom { display: none!important; }\n";
  264. }
  265. }
  266. css += ".ytp-gradient-top { display: none!important; }\n";
  267. css += "\n";
  268. return css;
  269. };
  270. YtNewUIFix.prototype.addExtras = function (css) {
  271. if (this.showControlsFullscreen) {
  272. 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";
  273. css += ".html5-video-player.ytp-fullscreen:not(.ytp-hide-controls) .ytp-chrome-bottom { opacity: 1!important; display: block!important; }\n";
  274. }
  275. if (this.showControlsNonFullscreen) {
  276. 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";
  277. css += ".html5-video-player:not(.ytp-fullscreen):not(.ytp-hide-controls) .ytp-chrome-bottom { opacity: 1!important; display: block!important; }\n";
  278. if (!this.isEmbedded) {
  279. 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";
  280. }
  281. css += "html.floater .html5-video-player, html.iri-always-visible .html5-video-player { padding-bottom: 35px; }\n";
  282. css += "#theater-background { padding-bottom: 35px; }\n\n";
  283. css += "#placeholder-player { padding-bottom: 35px; }\n";
  284. }
  285. if (!this.showControlsFullscreen && !this.showControlsNonFullscreen) {
  286. css += ".html5-video-player .html5-main-video { height: 100%!important; }\n";
  287. }
  288. if (this.removeAnimations) {
  289. css += ".ytp-bezel { display: none!important; }\n";
  290. css += ".html5-endscreen *, .html5-video-player div { transition-property: none !important; animation: none !important; }\n";
  291. }
  292. if (this.optionsReversed) {
  293. css += ".ytp-panel { display: -webkit-flex; -webkit-flex-direction: column; display: flex; flex-direction: column; }\n";
  294. css += ".ytp-panel-header { order: 2; border-top: 1px solid #444; border-bottom: none; }\n";
  295. css += ".ytp-panel-content { order: 1; }\n";
  296. }
  297. if (this.alwaysVolume) {
  298. /* Have the volume slider always be visible */
  299. css += ".ytp-volume-panel { width: 52px; margin-right: 3px; } .ytp-big-mode .ytp-volume-panel { width: 78px; }";
  300. }
  301. if (this.progressBigger) {
  302. /* Make the progressbar fill up the entire space when not hovering over (thanks to Takato) */
  303. 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; }";
  304. 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; }";
  305. }
  306. return css;
  307. };
  308. YtNewUIFix.prototype.showOptions = function () {
  309. var options = document.querySelectorAll("#YoutubeNewUIFix-Options input");
  310. if (options.length > 0) {
  311. for (var i = 0; i < options.length; i++) {
  312. options[i].checked = (this.getSetting(options[i].name) === "true");
  313. }
  314. }
  315. };
  316. YtNewUIFix.prototype.addOptions = function () {
  317. var _this = this;
  318. if (localStorage) {
  319. var accSection_1 = document.createElement("div");
  320. accSection_1.id = "YoutubeNewUIFix-Options";
  321. accSection_1.classList.add("account-section");
  322. var header = document.createElement("h3");
  323. header.classList.add("account-section-header");
  324. header.textContent = "Youtube UI Fix Options";
  325. accSection_1.appendChild(header);
  326. {
  327. accSection_1.appendChild(this.createOption("addWatchLater", "Add the watch later button to the controls"));
  328. accSection_1.appendChild(this.createOption("changeColorsNonFullscreen", "Change the colors back to their original gray (in non-full-screen mode)"));
  329. accSection_1.appendChild(this.createOption("changeColorsFullscreen", "Change the colors back to their original gray in full-screen mode"));
  330. accSection_1.appendChild(this.createOption("showControlsNonFullscreen", "Always show the controls (in non-full-screen mode)"));
  331. accSection_1.appendChild(this.createOption("showControlsFullscreen", "Always show the controls in full-screen mode"));
  332. accSection_1.appendChild(this.createOption("removeAnimations", "Remove all animations"));
  333. accSection_1.appendChild(this.createOption("optionsReversed", "Move the 'go back' button in the settings menus to the bottom"));
  334. accSection_1.appendChild(this.createOption("progressBigger", "Make the progressbar take up the whole width (but not when hovering over)"));
  335. accSection_1.appendChild(this.createOption("alwaysVolume", "Have the volume slider be always visible"));
  336. }
  337. var content = document.querySelector(".account-content");
  338. var footer = document.querySelector(".account-footer");
  339. var selectedItem = document.querySelector(".creator-sidebar-item.selected");
  340. if (!content) {
  341. content = document.querySelector("#contents");
  342. if (!content) {
  343. return;
  344. }
  345. }
  346. if (!selectedItem) {
  347. selectedItem = document.querySelector(".ytd-settings-sidebar-renderer[active]");
  348. }
  349. if (this.isSettingsPage) {
  350. document.head.innerHTML = document.body.innerHTML = "";
  351. document.body.appendChild(accSection_1);
  352. }
  353. else if (content && selectedItem.innerHTML.indexOf("Playback") >= 0) {
  354. if (footer) {
  355. content.insertBefore(accSection_1, footer);
  356. }
  357. else {
  358. content.appendChild(accSection_1);
  359. }
  360. }
  361. var exportBtn_1 = document.createElement("button");
  362. exportBtn_1.classList.add("yt-uix-button", "yt-uix-button-size-default", "yt-uix-button-primary", "account-action-button");
  363. exportBtn_1.type = "button";
  364. exportBtn_1.textContent = "Export Settings";
  365. exportBtn_1.onclick = function () {
  366. var settingsScript = "// ==UserScript==\n";
  367. settingsScript += "// @name Youtube UI Fix Settings\n";
  368. settingsScript += "// @namespace YtUIFix\n";
  369. settingsScript += "// @description Sets the settings for Youtube UI Fix\n";
  370. settingsScript += "// @author Roy Scheerens\n";
  371. settingsScript += "// @homepageURL https://greasyfork.org/en/scripts/11485\n";
  372. settingsScript += "// @include https://www.youtube.com*\n";
  373. settingsScript += "// @include https://youtube.googleapis.com/embed*\n";
  374. settingsScript += "// @include https://www.youtube-nocookie.com/embed*\n";
  375. settingsScript += "// @version 0.0.1\n";
  376. settingsScript += "// @grant none\n";
  377. settingsScript += "// ==/UserScript==\n";
  378. settingsScript += "\n";
  379. settingsScript += "localStorage.setItem('ytfix::addWatchLater', String(" + String(_this["addWatchLater"]) + "));\n";
  380. settingsScript += "localStorage.setItem('ytfix::showControlsFullscreen', String(" + String(_this["showControlsFullscreen"]) + "));\n";
  381. settingsScript += "localStorage.setItem('ytfix::showControlsNonFullscreen', String(" + String(_this["showControlsNonFullscreen"]) + "));\n";
  382. settingsScript += "localStorage.setItem('ytfix::changeColorsFullscreen', String(" + String(_this["changeColorsFullscreen"]) + "));\n";
  383. settingsScript += "localStorage.setItem('ytfix::changeColorsNonFullscreen', String(" + String(_this["changeColorsNonFullscreen"]) + "));\n";
  384. settingsScript += "localStorage.setItem('ytfix::removeAnimations', String(" + String(_this["removeAnimations"]) + "));\n";
  385. settingsScript += "localStorage.setItem('ytfix::optionsReversed', String(" + String(_this["optionsReversed"]) + "));\n";
  386. settingsScript += "localStorage.setItem('ytfix::progressBigger', String(" + String(_this["progressBigger"]) + "));\n";
  387. settingsScript += "localStorage.setItem('ytfix::alwaysVolume', String(" + String(_this["alwaysVolume"]) + "));\n";
  388. var hiddenText = accSection_1.getElementsByTagName("textarea")[0] || document.createElement("textarea");
  389. hiddenText.textContent = settingsScript;
  390. accSection_1.appendChild(hiddenText);
  391. hiddenText.select();
  392. document.execCommand("cut");
  393. accSection_1.removeChild(hiddenText);
  394. exportBtn_1.innerHTML = "Settings Userscipt Copied";
  395. };
  396. if (footer) {
  397. footer.appendChild(exportBtn_1);
  398. }
  399. else {
  400. content.appendChild(exportBtn_1);
  401. }
  402. }
  403. };
  404. YtNewUIFix.prototype.createOption = function (name, description) {
  405. var _this = this;
  406. var accDiv = document.createElement("div");
  407. accDiv.classList.add("account-section-setting");
  408. 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>";
  409. var accInput = accDiv.querySelector("input[name='" + name + "']");
  410. accInput.onclick = function () {
  411. _this.setSetting(name, accInput.checked);
  412. _this[name] = accInput.checked;
  413. };
  414. return accDiv;
  415. };
  416. return YtNewUIFix;
  417. }());
  418. new YtNewUIFix().applyFix();