Advertisement
xX_LegendCraftd_Xx

Fixes for CSS version of the non-rounded design

Jan 22nd, 2024 (edited)
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.76 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Fixes for CSS version of the non-rounded design
  3. // @version 20240424.18.10
  4. // @description This userscript will fix issues with the CSS version of the non-rounded design. It also includes shorts redirect and the return of the explore tab.
  5. // @author Magma_Craft
  6. // @license MIT
  7. // @match https://www.youtube.com/*
  8. // @namespace https://greasyfork.org/en/users/933798
  9. // @icon https://www.youtube.com/favicon.ico
  10. // @run-at document-end
  11. // @grant none
  12. // ==/UserScript==
  13. (function() {
  14. window['yt'] = window['yt'] || {};
  15. yt['config_'] = yt.config_ || {};
  16. yt.config_['EXPERIMENT_FLAGS'] = yt.config_.EXPERIMENT_FLAGS || {};
  17.  
  18. var iv = setInterval(function() {
  19. yt.config_.EXPERIMENT_FLAGS.kevlar_refresh_on_theme_change = false;
  20. yt.config_.EXPERIMENT_FLAGS.kevlar_watch_cinematics = false;
  21. yt.config_.EXPERIMENT_FLAGS.kevlar_watch_grid = false;
  22. yt.config_.EXPERIMENT_FLAGS.kevlar_watch_grid_hide_chips = false;
  23. yt.config_.EXPERIMENT_FLAGS.kevlar_watch_metadata_refresh_no_old_secondary_data = false;
  24. yt.config_.EXPERIMENT_FLAGS.enable_channel_page_header_profile_section = false;
  25. yt.config_.EXPERIMENT_FLAGS.kevlar_modern_sd_v2 = false;
  26. yt.config_.EXPERIMENT_FLAGS.kevlar_watch_comments_panel_button = false;
  27. yt.config_.EXPERIMENT_FLAGS.smartimation_background = false;
  28. yt.config_.EXPERIMENT_FLAGS.web_animated_actions = false;
  29. yt.config_.EXPERIMENT_FLAGS.web_animated_like = false;
  30. yt.config_.EXPERIMENT_FLAGS.web_animated_like_lazy_load = false;
  31. yt.config_.EXPERIMENT_FLAGS.web_modern_collections_v2 = false;
  32. yt.config_.EXPERIMENT_FLAGS.web_modern_tabs = false;
  33. yt.config_.EXPERIMENT_FLAGS.web_modern_typography = false;
  34. yt.config_.EXPERIMENT_FLAGS.web_enable_youtab = false;
  35. yt.config_.EXPERIMENT_FLAGS.web_watch_rounded_player_large = false
  36. // Extra additions to remove the watch grid UI
  37. yt.config_.EXPERIMENT_FLAGS.web_player_enable_featured_product_banner_exclusives_on_desktop = false,
  38. yt.config_.EXPERIMENT_FLAGS.kevlar_watch_comments_panel_button = false,
  39. yt.config_.EXPERIMENT_FLAGS.fill_view_models_on_web_vod = true,
  40. yt.config_.EXPERIMENT_FLAGS.kevlar_watch_flexy_metadata_height = 136,
  41. yt.config_.EXPERIMENT_FLAGS.kevlar_watch_max_player_width = 1280,
  42. yt.config_.EXPERIMENT_FLAGS.live_chat_over_engagement_panels = false,
  43. yt.config_.EXPERIMENT_FLAGS.live_chat_scaled_height = false,
  44. yt.config_.EXPERIMENT_FLAGS.live_chat_smaller_min_height = false,
  45. yt.config_.EXPERIMENT_FLAGS.main_app_controller_extraction_batch_18 = false,
  46. yt.config_.EXPERIMENT_FLAGS.main_app_controller_extraction_batch_19 = false,
  47. yt.config_.EXPERIMENT_FLAGS.no_iframe_for_web_stickiness = false,
  48. yt.config_.EXPERIMENT_FLAGS.optimal_reading_width_comments_ep = false,
  49. yt.config_.EXPERIMENT_FLAGS.remove_masthead_channel_banner_on_refresh = false,
  50. yt.config_.EXPERIMENT_FLAGS.small_avatars_for_comments = false,
  51. yt.config_.EXPERIMENT_FLAGS.small_avatars_for_comments_ep = false,
  52. yt.config_.EXPERIMENT_FLAGS.web_watch_compact_comments = false,
  53. yt.config_.EXPERIMENT_FLAGS.web_watch_compact_comments_header = false,
  54. yt.config_.EXPERIMENT_FLAGS.web_watch_log_theater_mode = false,
  55. yt.config_.EXPERIMENT_FLAGS.web_watch_theater_chat = false,
  56. yt.config_.EXPERIMENT_FLAGS.web_watch_theater_fixed_chat = false,
  57. yt.config_.EXPERIMENT_FLAGS.wn_grid_max_item_width = 0,
  58. yt.config_.EXPERIMENT_FLAGS.wn_grid_min_item_width = 0
  59. }, 1);
  60.  
  61. var to = setTimeout(function() {
  62. clearInterval(iv);
  63. }, 1000)
  64. })();
  65.  
  66. // Shorts URL redirect
  67. var oldHref = document.location.href;
  68. if (window.location.href.indexOf('youtube.com/shorts') > -1) {
  69. window.location.replace(window.location.toString().replace('/shorts/', '/watch?v='));
  70. }
  71. window.onload = function() {
  72. var bodyList = document.querySelector("body")
  73. var observer = new MutationObserver(function(mutations) {
  74. mutations.forEach(function(mutation) {
  75. if (oldHref != document.location.href) {
  76. oldHref = document.location.href;
  77. console.log('location changed!');
  78. if (window.location.href.indexOf('youtube.com/shorts') > -1) {
  79. window.location.replace(window.location.toString().replace('/shorts/', '/watch?v='));
  80. }
  81. }
  82. });
  83. });
  84. var config = {
  85. childList: true,
  86. subtree: true
  87. };
  88. observer.observe(bodyList, config);
  89. };
  90.  
  91. //Re-add 'Explore' tab from the sidebar menu
  92. function waitForElm(selector) {
  93. return new Promise(resolve => {
  94. if (document.querySelector(selector)) {
  95. return resolve(document.querySelector(selector));
  96. }
  97.  
  98. const observer = new MutationObserver(mutations => {
  99. if (document.querySelector(selector)) {
  100. resolve(document.querySelector(selector));
  101. observer.disconnect();
  102. }
  103. });
  104.  
  105. observer.observe(document.body, {
  106. childList: true,
  107. subtree: true
  108. });
  109. });
  110. }
  111.  
  112. function restoreTrending() {
  113.  
  114. var trendingData = {
  115. "navigationEndpoint": {
  116. "clickTrackingParams": "CBwQtSwYASITCNqYh-qO_fACFcoRrQYdP44D9Q==",
  117. "commandMetadata": {
  118. "webCommandMetadata": {
  119. "url": "/feed/explore",
  120. "webPageType": "WEB_PAGE_TYPE_BROWSE",
  121. "rootVe": 6827,
  122. "apiUrl": "/youtubei/v1/browse"
  123. }
  124. },
  125. "browseEndpoint": {
  126. "browseId": "FEtrending"
  127. }
  128. },
  129. "icon": {
  130. "iconType": "EXPLORE"
  131. },
  132. "trackingParams": "CBwQtSwYASITCNqYh-qO_fACFcoRrQYdP44D9Q==",
  133. "formattedTitle": {
  134. "simpleText": "Explore"
  135. },
  136. "accessibility": {
  137. "accessibilityData": {
  138. "label": "Explore"
  139. }
  140. },
  141. "isPrimary": true
  142. };
  143.  
  144. var guidetemplate = `<ytd-guide-entry-renderer class="style-scope ytd-guide-section-renderer" is-primary="" line-end-style="none"><!--css-build:shady--><a id="endpoint" class="yt-simple-endpoint style-scope ytd-guide-entry-renderer" tabindex="-1" role="tablist"><tp-yt-paper-item role="tab" class="style-scope ytd-guide-entry-renderer" tabindex="0" aria-disabled="false"><!--css-build:shady--><yt-icon class="guide-icon style-scope ytd-guide-entry-renderer" disable-upgrade=""></yt-icon><yt-img-shadow height="24" width="24" class="style-scope ytd-guide-entry-renderer" disable-upgrade=""></yt-img-shadow><yt-formatted-string class="title style-scope ytd-guide-entry-renderer"><!--css-build:shady--></yt-formatted-string><span class="guide-entry-count style-scope ytd-guide-entry-renderer"></span><yt-icon class="guide-entry-badge style-scope ytd-guide-entry-renderer" disable-upgrade=""></yt-icon><div id="newness-dot" class="style-scope ytd-guide-entry-renderer"></div></tp-yt-paper-item></a><yt-interaction class="style-scope ytd-guide-entry-renderer"><!--css-build:shady--><div class="stroke style-scope yt-interaction"></div><div class="fill style-scope yt-interaction"></div></yt-interaction></ytd-guide-entry-renderer>`;
  145. document.querySelector(`#items > ytd-guide-entry-renderer:nth-child(2)`).data = trendingData;
  146.  
  147. var miniguidetemplate = `<ytd-mini-guide-entry-renderer class="style-scope ytd-mini-guide-section-renderer" is-primary="" line-end-style="none"><!--css-build:shady--><a id="endpoint" class="yt-simple-endpoint style-scope ytd-guide-entry-renderer" tabindex="-1" role="tablist"><tp-yt-paper-item role="tab" class="style-scope ytd-guide-entry-renderer" tabindex="0" aria-disabled="false"><!--css-build:shady--><yt-icon class="guide-icon style-scope ytd-guide-entry-renderer" disable-upgrade=""></yt-icon><yt-img-shadow height="24" width="24" class="style-scope ytd-guide-entry-renderer" disable-upgrade=""></yt-img-shadow><yt-formatted-string class="title style-scope ytd-guide-entry-renderer"><!--css-build:shady--></yt-formatted-string><span class="guide-entry-count style-scope ytd-guide-entry-renderer"></span><yt-icon class="guide-entry-badge style-scope ytd-guide-entry-renderer" disable-upgrade=""></yt-icon><div id="newness-dot" class="style-scope ytd-guide-entry-renderer"></div></tp-yt-paper-item></a><yt-interaction class="style-scope ytd-guide-entry-renderer"><!--css-build:shady--><div class="stroke style-scope yt-interaction"></div><div class="fill style-scope yt-interaction"></div></yt-interaction></ytd-guide-entry-renderer>`;
  148. document.querySelector(`#items > ytd-mini-guide-entry-renderer:nth-child(2)`).data = trendingData;
  149.  
  150. }
  151.  
  152.  
  153. waitForElm("#items.ytd-guide-section-renderer").then((elm) => {
  154. restoreTrending();
  155. });
  156.  
  157. waitForElm("#items.ytd-mini-guide-section-renderer").then((elm) => {
  158. restoreTrending();
  159. });
  160.  
  161. // Include the watch action buttons fix script that issued on older browsers
  162. const abtnconfig = {
  163. unsegmentLikeButton: false,
  164. noFlexibleItems: true
  165. };
  166.  
  167. function updateBtns() {
  168. var watchFlexy = document.querySelector("ytd-watch-flexy");
  169. var results = watchFlexy.data.contents.twoColumnWatchNextResults.results.results.contents;
  170.  
  171. for (var i = 0; i < results.length; i++) {
  172. if (results[i].videoPrimaryInfoRenderer) {
  173. var actions = results[i].videoPrimaryInfoRenderer.videoActions.menuRenderer;
  174.  
  175. if (abtnconfig.unsegmentLikeButton) {
  176. if (actions.topLevelButtons[0].segmentedLikeDislikeButtonRenderer) {
  177. var segmented = actions.topLevelButtons[0].segmentedLikeDislikeButtonRenderer;
  178. actions.topLevelButtons.splice(0, 1);
  179. actions.topLevelButtons.unshift(segmented.dislikeButton);
  180. actions.topLevelButtons.unshift(segmented.likeButton);
  181. }
  182. }
  183.  
  184. if (abtnconfig.noFlexibleItems) {
  185. for (var i = 0; i < actions.flexibleItems.length; i++) {
  186. actions.topLevelButtons.push(actions.flexibleItems[i].menuFlexibleItemRenderer.topLevelButton);
  187. }
  188.  
  189. delete actions.flexibleItems
  190. }
  191. }
  192. }
  193.  
  194. var temp = watchFlexy.data;
  195. watchFlexy.data = {};
  196. watchFlexy.data = temp;
  197. }
  198.  
  199. document.addEventListener("yt-page-data-updated", (e) => {
  200. if (e.detail.pageType == "watch") {
  201. updateBtns();
  202. }
  203. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement