Youtube UI Fix

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

当前为 2020-12-11 提交的版本,查看 最新版本

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