Youtube New UI Fix

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

当前为 2016-10-26 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Youtube New UI Fix
  3. // @namespace YtNewUIFix
  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-youtube-new-ui-fix
  7. // @include https://www.youtube.com/*
  8. // @include https://youtube.googleapis.com/embed/*
  9. // @include https://www.youtube-nocookie.com/embed/*
  10. // @version 2.3.3
  11. // @grant none
  12. // ==/UserScript==
  13. /* Original typescript code: https://mega.nz/#!RUw3zADT!JaRR7h4jwYVsrX_OqK5scvcLg4tUVfaCr_nJV21taUk */
  14. var YtNewUIFix = (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().indexOf("ui_fix_settings") >= 0;
  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.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.checkMoviePlayer = function () {
  74. if (!this.moviePlayer || !this.moviePlayer.parentNode) {
  75. this.moviePlayer = document.querySelector("div.html5-video-player");
  76. }
  77. if (this.moviePlayer && this.moviePlayer.parentNode) {
  78. if (!this.moviePlayer.classList.contains("seeking-mode") &&
  79. !this.moviePlayer.classList.contains("dragging-mode") &&
  80. (this.showControlsNonFullscreen && !this.moviePlayer.classList.contains("ytp-fullscreen") || this.showControlsFullscreen && this.moviePlayer.classList.contains("ytp-fullscreen"))) {
  81. this.moviePlayer.dispatchEvent(this.mouseMoveEvent);
  82. }
  83. if (this.showTitleOnHover) {
  84. this.moviePlayer.classList.remove("ytp-hide-info-bar");
  85. }
  86. }
  87. };
  88. YtNewUIFix.prototype.handleWatchLater = function () {
  89. if (!this.watchLaterbutton || !this.settingsButton) {
  90. this.watchLaterbutton = document.querySelector(".ytp-chrome-top .ytp-watch-later-button");
  91. this.settingsButton = document.querySelector(".ytp-settings-button");
  92. if (this.watchLaterbutton) {
  93. this.oldWatchParent = this.watchLaterbutton.parentElement;
  94. }
  95. }
  96. if (this.watchLaterbutton && this.settingsButton) {
  97. if (this.addWatchLater) {
  98. this.settingsButton.parentNode.insertBefore(this.watchLaterbutton, this.settingsButton);
  99. }
  100. else {
  101. this.oldWatchParent.appendChild(this.watchLaterbutton);
  102. }
  103. }
  104. };
  105. YtNewUIFix.prototype.addCSS = function () {
  106. var css = "";
  107. css = this.fixColors(css);
  108. css = this.fixControls(css);
  109. css = this.fixBigMode(css);
  110. css = this.addExtras(css);
  111. var style = document.getElementById("YoutubeNewUIFix-Style");
  112. if (style) {
  113. style.parentNode.removeChild(style);
  114. delete style.textContent;
  115. }
  116. style = document.createElement("style");
  117. style.id = "YoutubeNewUIFix-Style";
  118. style.textContent = css;
  119. document.head.appendChild(style);
  120. };
  121. YtNewUIFix.prototype.fixControls = function (css) {
  122. // options
  123. css += "h3.optionChanged::after { content: 'Refresh page to save changes'; color: red; position: relative; left: 15px; }\n\n";
  124. css += ".account-content-on-player { top: 0px; left: 0px; position: absolute; padding: 0; margin: 0; width: 100%; height: 100% }";
  125. css += ".account-content-on-player account-section { top: 50px; left: 50px; z-index: 100; background-color: white; padding: 10px 25px 30px; margin: 0; }";
  126. css += ".html5-video-player.ytp-fullscreen .html5-video-container { height: 100vh; }";
  127. css += ".html5-video-player:not(.ytp-fullscreen) .html5-video-container { height: 100%; }";
  128. css += ".ytp-chrome-bottom { left: 0 !important; }\n";
  129. css += ".ytp-chrome-controls { margin: 0 -12px; }\n";
  130. css += "body:not(.ytwp-window-player) #page:not(.watch-stage-mode) #watch7-sidebar { transform: translateY(-35px); }\n";
  131. css += "body:not(.ytwp-window-player) #page.watch-stage-mode #watch-appbar-playlist { margin-top: 35px; }\n";
  132. css += ".html5-main-video { top: 0!important; }\n";
  133. // progressbar
  134. css += ".ytp-progress-bar-container:not(.ytp-pulling) { height: 5px!important; bottom: 30px!important; }\n";
  135. css += ".ytp-progress-list { transform-origin: center top; }\n\n";
  136. css += ".ytp-big-mode .ytp-progress-list { transform: scaleY(0.6); }\n\n";
  137. // scale down
  138. css += ".ytp-chrome-bottom { height: 35px!important; padding: 0!important; }\n";
  139. css += ".ytp-chrome-controls .ytp-button:not(.ytp-watch-later-button) { width: 33px!important; }\n";
  140. css += ".ytp-chrome-controls .ytp-watch-later-button { width: 24px!important; }\n";
  141. css += ".ytp-left-controls { margin-left: 5px }\n";
  142. css += ".ytp-time-display { height: 31px; line-height: 32px!important; font-size: 12px!important; }\n";
  143. css += ".ytp-left-controls, .ytp-right-controls { height: 32px!important; margin-top: 3px; line-height: 36px; }\n\n";
  144. // badges
  145. 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";
  146. css += ".ytp-settings-button.ytp-hd-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik01LDcgTDYsNyBMNiw4IEw1LDggTDUsNyBaIE0xMCwzIEwxMCw0IEw4LDQgTDgsMyBMMTAsMyBaIE0zLDYgTDMsNSBMNSw1IEw1LDYgTDMsNiBaIE0yLDcgTDMsNyBMMyw4IEwyLDggTDIsNyBaIE03LDcgTDEwLDcgTDEwLDggTDcsOCBMNyw3IFogTTEwLDYgTDExLDYgTDExLDcgTDEwLDcgTDEwLDYgWiIgZmlsbD0iIzAwMCIgZmlsbC1vcGFjaXR5PSIwLjY0NzEiIGZpbGwtcnVsZT0iZXZlbm9kZCIgLz48cGF0aCBkPSJNNSw3IEw1LDYgTDUsNSBMMyw1IEwzLDYgTDMsNyBMMiw3IEwyLDIgTDMsMiBMMyw0IEw1LDQgTDUsMiBMNiwyIEw2LDcgTDUsNyBaIE0xMSw2IEwxMCw2IEwxMCw3IEw3LDcgTDcsMiBMMTAsMiBMMTAsMyBMMTEsMyBMMTEsNiBaIE0xMCw0IEwxMCwzIEw4LDMgTDgsNCBMOCw2IEwxMCw2IEwxMCw0IFoiIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgLz48L3N2Zz4=)!important; }";
  147. css += ".ytp-settings-button.ytp-4k-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik0xMCw0IEwxMSw0IEwxMSw1IEwxMCw1IEwxMCw0IFogTTEwLDcgTDExLDcgTDExLDggTDEwLDggTDEwLDcgWiBNOCw1IEwxMCw1IEwxMCw2IEw4LDYgTDgsNSBaIE03LDcgTDgsNyBMOCw4IEw3LDggTDcsNyBaIE01LDYgTDYsNiBMNiw3IEw1LDcgTDUsNiBaIE00LDcgTDUsNyBMNSw4IEw0LDggTDQsNyBaIE0yLDYgTDQsNiBMNCw3IEwyLDcgTDIsNiBaIE0zLDQgTDQsNCBMNCw1IEwzLDUgTDMsNCBaIiBmaWxsPSIjMDAwIiBmaWxsLW9wYWNpdHk9IjAuNjQ3MSIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjxwYXRoIGQ9Ik0xMSw1IEwxMSw3IEwxMCw3IEwxMCw2IEwxMCw1IEwxMSw1IFogTTEwLDUgTDgsNSBMOCw2IEw4LDcgTDcsNyBMNywyIEw4LDIgTDgsNCBMMTAsNCBMMTAsNSBaIE00LDQgTDMsNCBMMyw1IEw0LDUgTDQsNCBaIE00LDcgTDQsNiBMMiw2IEwyLDQgTDMsNCBMMywzIEw0LDMgTDQsMiBMNSwyIEw1LDUgTDYsNSBMNiw2IEw1LDYgTDUsNyBMNCw3IFogTTEwLDIgTDExLDIgTDExLDQgTDEwLDQgTDEwLDIgWiIgZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjwvc3ZnPg==)!important; }";
  148. css += ".ytp-settings-button.ytp-5k-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik0xMCw0IEwxMSw0IEwxMSw1IEwxMCw1IEwxMCw0IFogTTEwLDcgTDExLDcgTDExLDggTDEwLDggTDEwLDcgWiBNOCw1IEwxMCw1IEwxMCw2IEw4LDYgTDgsNSBaIE03LDcgTDgsNyBMOCw4IEw3LDggTDcsNyBaIE01LDYgTDYsNiBMNiw3IEw1LDcgTDUsNiBaIE0yLDcgTDUsNyBMNSw4IEwyLDggTDIsNyBaIE0yLDUgTDUsNSBMNSw2IEwyLDYgTDIsNSBaIiBmaWxsPSIjMDAwIiBmaWxsLW9wYWNpdHk9IjAuNjQ3MSIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjxwYXRoIGQ9Ik0xMSw1IEwxMSw3IEwxMCw3IEwxMCw2IEwxMCw1IEwxMSw1IE0xMCw1IEw4LDUgTDgsNiBMOCw3IEw3LDcgTDcsMiBMOCwyIEw4LDQgTDEwLDQgTDEwLDUgTTEwLDIgTDExLDIgTDExLDQgTDEwLDQgTDEwLDIgTTIsNiBMNSw2IEw1LDcgTDIsNyBNNSw1IEw2LDUgTDYsNiBMNSw2IE01LDQgTDMsNCBMMywzIEw2LDMgTDYsMiBMMiwyIEwyLDUgTDUsNSBMNSw0IFoiIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgLz48L3N2Zz4=)!important; }";
  149. css += ".ytp-settings-button.ytp-8k-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik0xMCw0IEwxMSw0IEwxMSw1IEwxMCw1IEwxMCw0IFogTTEwLDcgTDExLDcgTDExLDggTDEwLDggTDEwLDcgWiBNOCw1IEwxMCw1IEwxMCw2IEw4LDYgTDgsNSBaIE03LDcgTDgsNyBMOCw4IEw3LDggTDcsNyBaIE01LDYgTDYsNiBMNiw3IEw1LDcgTDUsNiBaIE0zLDUgTDUsNSBMNSw2IEwzLDYgTDMsNSBaIE0zLDMgTDUsMyBMNSw0IEwzLDQgTDMsMyBaIE01LDQgTDYsNCBMNiw1IEw1LDUgTDUsNCBaIE0yLDQgTDMsNCBMMyw1IEwyLDUgTDIsNCBaIE0yLDYgTDMsNiBMMyw3IEwyLDcgTDIsNiBaIE0zLDcgTDUsNyBMNSw4IEwzLDggTDMsNyBaIiBmaWxsPSIjMDAwIiBmaWxsLW9wYWNpdHk9IjAuNjQ3MSIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjxwYXRoIGQ9Ik0xMSw1IEwxMSw3IEwxMCw3IEwxMCw2IEwxMCw1IEwxMSw1IE0xMCw1IEw4LDUgTDgsNiBMOCw3IEw3LDcgTDcsMiBMOCwyIEw4LDQgTDEwLDQgTDEwLDUgTTEwLDIgTDExLDIgTDExLDQgTDEwLDQgTDEwLDIgTTMsNiBMNSw2IEw1LDcgTDMsNyBNMywyIEw1LDIgTDUsMyBMMywzIEwzLDIgWiBNNSw1IEw2LDUgTDYsNiBMNSw2IEw1LDUgWiBNMyw0IEw1LDQgTDUsNSBMMyw1IEwzLDQgWiBNNSwzIEw2LDMgTDYsNCBMNSw0IEw1LDMgWiBNMiw1IEwzLDUgTDMsNiBMMiw2IEwyLDUgWiBNMiwzIEwzLDMgTDMsNCBMMiw0IEwyLDMgWiIgZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjwvc3ZnPg==)!important; }";
  150. 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; }";
  151. css += ".ytp-color-white .ytp-settings-button.ytp-hd-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik01LDcgTDUsNiBMNSw1IEwzLDUgTDMsNiBMMyw3IEwyLDcgTDIsMiBMMywyIEwzLDQgTDUsNCBMNSwyIEw2LDIgTDYsNyBMNSw3IFogTTExLDYgTDEwLDYgTDEwLDcgTDcsNyBMNywyIEwxMCwyIEwxMCwzIEwxMSwzIEwxMSw2IFogTTEwLDQgTDEwLDMgTDgsMyBMOCw0IEw4LDYgTDEwLDYgTDEwLDQgWiIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjwvc3ZnPg==)!important; }";
  152. css += ".ytp-color-white .ytp-settings-button.ytp-4k-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik0xMSw1IEwxMSw3IEwxMCw3IEwxMCw2IEwxMCw1IEwxMSw1IFogTTEwLDUgTDgsNSBMOCw2IEw4LDcgTDcsNyBMNywyIEw4LDIgTDgsNCBMMTAsNCBMMTAsNSBaIE00LDQgTDMsNCBMMyw1IEw0LDUgTDQsNCBaIE00LDcgTDQsNiBMMiw2IEwyLDQgTDMsNCBMMywzIEw0LDMgTDQsMiBMNSwyIEw1LDUgTDYsNSBMNiw2IEw1LDYgTDUsNyBMNCw3IFogTTEwLDIgTDExLDIgTDExLDQgTDEwLDQgTDEwLDIgWiIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjwvc3ZnPg==)!important; }";
  153. css += ".ytp-color-white .ytp-settings-button.ytp-5k-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik0xMSw1IEwxMSw3IEwxMCw3IEwxMCw2IEwxMCw1IEwxMSw1IE0xMCw1IEw4LDUgTDgsNiBMOCw3IEw3LDcgTDcsMiBMOCwyIEw4LDQgTDEwLDQgTDEwLDUgTTEwLDIgTDExLDIgTDExLDQgTDEwLDQgTDEwLDIgTTIsNiBMNSw2IEw1LDcgTDIsNyBNNSw1IEw2LDUgTDYsNiBMNSw2IE01LDQgTDMsNCBMMywzIEw2LDMgTDYsMiBMMiwyIEwyLDUgTDUsNSBMNSw0IFoiIGZpbGwtcnVsZT0iZXZlbm9kZCIgLz48L3N2Zz4=)!important; }";
  154. css += ".ytp-color-white .ytp-settings-button.ytp-8k-quality-badge:after { background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwJSIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMgOSIgd2lkdGg9IjEwMCUiPjxwYXRoIGQ9Ik0xMSw1IEwxMSw3IEwxMCw3IEwxMCw2IEwxMCw1IEwxMSw1IE0xMCw1IEw4LDUgTDgsNiBMOCw3IEw3LDcgTDcsMiBMOCwyIEw4LDQgTDEwLDQgTDEwLDUgTTEwLDIgTDExLDIgTDExLDQgTDEwLDQgTDEwLDIgTTMsNiBMNSw2IEw1LDcgTDMsNyBNMywyIEw1LDIgTDUsMyBMMywzIEwzLDIgWiBNNSw1IEw2LDUgTDYsNiBMNSw2IEw1LDUgWiBNMyw0IEw1LDQgTDUsNSBMMyw1IEwzLDQgWiBNNSwzIEw2LDMgTDYsNCBMNSw0IEw1LDMgWiBNMiw1IEwzLDUgTDMsNiBMMiw2IEwyLDUgWiBNMiwzIEwzLDMgTDMsNCBMMiw0IEwyLDMgWiIgZmlsbC1ydWxlPSJldmVub2RkIiAvPjwvc3ZnPg==)!important; }";
  155. 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; }";
  156. // closed captions (line under the button, and position of captions)
  157. css += ".ytp-chrome-controls .ytp-button[aria-pressed='true']::after { width: 18px; left: 8px; }\n";
  158. css += ".caption-window.ytp-caption-window-bottom { margin-bottom:40px!important }\n";
  159. return css;
  160. };
  161. YtNewUIFix.prototype.fixBigMode = function (css) {
  162. /* big mode: smaller scrubber */
  163. css += ".ytp-big-mode .ytp-scrubber-button { height: 13px!important; width: 13px!important; border-radius: 6.5px!important; }\n";
  164. css += ".ytp-big-mode .ytp-scrubber-container { top: -4px; left: -6.5px; }\n\n";
  165. /* big mode: 24px edges instead of 12px */
  166. css += ".ytp-big-mode .ytp-left-controls { margin-left: -7px }\n";
  167. css += ".ytp-big-mode .ytp-fullscreen-button { margin-right: -7px }\n\n";
  168. /* big mode: smaller volume slider */
  169. css += ".ytp-big-mode .ytp-volume-slider-handle { width: 12px; height: 12px; border-radius: 6px; margin-top: -6px; }\n";
  170. css += ".ytp-big-mode .ytp-volume-slider-active .ytp-volume-panel { width: 72px; }\n\n";
  171. return css;
  172. };
  173. YtNewUIFix.prototype.fixColors = function (css) {
  174. if (this.changeColorsNonFullscreen) {
  175. 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";
  176. css += ".html5-video-player:not(.ytp-big-mode) .ytp-gradient-bottom { display: none!important; }\n";
  177. css += ".html5-video-player:not(.ytp-big-mode) .ytp-chrome-controls svg path { fill: #8E8E8E }\n";
  178. }
  179. else {
  180. css += ".html5-video-player:not(.ytp-big-mode) .ytp-chrome-bottom { border-left: 12px solid transparent; border-right: 12px solid transparent; }\n";
  181. if (this.showControlsNonFullscreen) {
  182. css += ".html5-video-player:not(.ytp-fullscreen) .ytp-gradient-bottom { display: none!important; }\n";
  183. }
  184. }
  185. if (this.changeColorsFullscreen) {
  186. css += ".ytp-big-mode .ytp-chrome-bottom { background-color: #1B1B1B; border-left: 24px solid #1B1B1B; border-right: 24px solid #1B1B1B; }\n";
  187. css += ".ytp-big-mode .ytp-gradient-bottom { display: none!important; }\n";
  188. css += ".ytp-big-mode .ytp-chrome-controls svg path { fill: #8E8E8E }\n";
  189. }
  190. else {
  191. css += ".ytp-big-mode .ytp-chrome-bottom { border-left: 24px solid transparent; border-right: 24px solid transparent; }\n";
  192. if (this.showControlsFullscreen) {
  193. css += ".html5-video-player.ytp-fullscreen .ytp-gradient-bottom { display: none!important; }\n";
  194. }
  195. }
  196. css += ".ytp-gradient-top { display: none!important; }\n";
  197. css += "\n";
  198. return css;
  199. };
  200. YtNewUIFix.prototype.addExtras = function (css) {
  201. if (this.showControlsFullscreen) {
  202. css += "html:not(.floater) .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";
  203. css += ".html5-video-player.ytp-fullscreen:not(.ytp-hide-controls) .ytp-chrome-bottom { opacity: 1!important; }\n";
  204. }
  205. if (this.showControlsNonFullscreen) {
  206. css += "html:not(.floater) .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";
  207. css += ".html5-video-player:not(.ytp-fullscreen):not(.ytp-hide-controls) .ytp-chrome-bottom { opacity: 1!important; }\n";
  208. css += "html:not(.floater):not(.part_fullbrowser) #movie_player:not(.ytp-fullscreen):not(.ytp-hide-controls) { height: calc(100% + 35px)!important; }\n";
  209. css += "html.floater .html5-video-player { padding-bottom: 35px; }\n";
  210. css += "#theater-background { padding-bottom: 35px; }\n\n";
  211. css += "#placeholder-player { padding-bottom: 35px; }\n";
  212. }
  213. if (!this.showControlsFullscreen && !this.showControlsNonFullscreen) {
  214. css += ".html5-video-player .html5-main-video { height: 100%!important; }\n";
  215. }
  216. if (!this.showTitleOnHover) {
  217. // hide always
  218. css += ".ytp-chrome-top { display: none!important; }\n";
  219. }
  220. if (this.removeAnimations) {
  221. css += ".ytp-bezel { display: none!important; }\n";
  222. css += ".html5-endscreen *, .html5-video-player div { transition-property: none !important; animation: none !important; }\n";
  223. }
  224. if (this.optionsReversed) {
  225. css += ".ytp-panel { display: -webkit-flex; -webkit-flex-direction: column; display: flex; flex-direction: column; }\n";
  226. css += ".ytp-panel-header { order: 2; border-top: 1px solid #444; border-bottom: none; }\n";
  227. css += ".ytp-panel-content { order: 1; }\n";
  228. }
  229. if (this.alwaysVolume) {
  230. /* Have the volume slider always be visible */
  231. css += ".ytp-volume-panel { width: 52px; margin-right: 3px; } .ytp-big-mode .ytp-volume-panel { width: 78px; }";
  232. }
  233. if (this.progressBigger) {
  234. /* Make the progressbar fill up the entire space when not hovering over (thanks to Takato) */
  235. css += ".ytp-progress-bar-container:not(:hover):not(.ytp-pulling) .ytp-progress-list { width: calc(100% + 24px); left: -12px; }";
  236. css += ".ytp-big-mode .ytp-progress-bar-container:not(:hover):not(.ytp-pulling) .ytp-progress-list { width: calc(100% + 48px); left: -24px; }";
  237. }
  238. return css;
  239. };
  240. YtNewUIFix.prototype.showOptions = function () {
  241. var options = document.querySelectorAll("#YoutubeNewUIFix-Options input");
  242. if (options.length > 0) {
  243. for (var i = 0; i < options.length; i++) {
  244. options[i].checked = (this.getSetting(options[i].name) === "true");
  245. }
  246. }
  247. };
  248. YtNewUIFix.prototype.addOptions = function () {
  249. if (localStorage) {
  250. var accSection = document.createElement("div");
  251. accSection.id = "YoutubeNewUIFix-Options";
  252. accSection.classList.add("account-section");
  253. var header = document.createElement("h3");
  254. header.classList.add("account-section-header");
  255. header.textContent = "Youtube New UI Fix Options";
  256. accSection.appendChild(header);
  257. {
  258. accSection.appendChild(this.createOption("addWatchLater", "Add the watch later button to the controls"));
  259. accSection.appendChild(this.createOption("changeColorsNonFullscreen", "Change the colors back to their original gray (in non-full-screen mode)"));
  260. accSection.appendChild(this.createOption("changeColorsFullscreen", "Change the colors back to their original gray in full-screen mode"));
  261. accSection.appendChild(this.createOption("showControlsNonFullscreen", "Always show the controls (in non-full-screen mode)"));
  262. accSection.appendChild(this.createOption("showControlsFullscreen", "Always show the controls in full-screen mode"));
  263. accSection.appendChild(this.createOption("removeAnimations", "Remove all animations"));
  264. accSection.appendChild(this.createOption("optionsReversed", "Move the 'go back' button in the settings menus to the bottom"));
  265. accSection.appendChild(this.createOption("progressBigger", "Make the progressbar take up the whole width (but not when hovering over)"));
  266. accSection.appendChild(this.createOption("showTitleOnHover", "Have the title show when hovering over the video"));
  267. accSection.appendChild(this.createOption("alwaysVolume", "Have the volume slider be always visible"));
  268. }
  269. var content = document.querySelector("div.account-content");
  270. var footer = document.querySelector("div.account-footer");
  271. if (this.isSettingsPage) {
  272. document.head.innerHTML = document.body.innerHTML = "";
  273. document.body.appendChild(accSection);
  274. }
  275. else if (content && footer) {
  276. content.insertBefore(accSection, footer);
  277. }
  278. }
  279. };
  280. YtNewUIFix.prototype.getSetting = function (key) {
  281. return localStorage.getItem(this.prefix + key);
  282. };
  283. YtNewUIFix.prototype.setSetting = function (key, value) {
  284. localStorage.setItem(this.prefix + key, String(value));
  285. };
  286. YtNewUIFix.prototype.createOption = function (name, description) {
  287. var _this = this;
  288. var accDiv = document.createElement("div");
  289. accDiv.classList.add("account-section-setting");
  290. accDiv.innerHTML = "\n\t\t <label>\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>";
  291. var accInput = accDiv.querySelector("input[name='" + name + "']");
  292. accInput.onclick = function () {
  293. _this.setSetting(name, accInput.checked);
  294. };
  295. return accDiv;
  296. };
  297. return YtNewUIFix;
  298. }());
  299. new YtNewUIFix().applyFix();
  300. //# sourceMappingURL=Youtube_New_UI_Fix.user.js.map