Action Buttons Fix (modified)

Fixes watch action buttons to be like how they used to be! (it also includes the old subscribed notification button before late 2022)

目前为 2023-09-29 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Action Buttons Fix (modified)
  3. // @version 1.0.1
  4. // @description Fixes watch action buttons to be like how they used to be! (it also includes the old subscribed notification button before late 2022)
  5. // @author xX_LegendCraftd_Xx
  6. // @icon https://www.youtube.com/favicon.ico
  7. // @namespace https://greasyfork.org/en/users/933798
  8. // @license MIT
  9. // @match https://*.youtube.com/*
  10. // @grant none
  11. // @run-at document-start
  12. // ==/UserScript==
  13.  
  14. const abtnconfig = {
  15. unsegmentLikeButton: false,
  16. noFlexibleItems: true
  17. };
  18.  
  19. function updateBtns() {
  20. var watchFlexy = document.querySelector("ytd-watch-flexy");
  21. var results = watchFlexy.data.contents.twoColumnWatchNextResults.results.results.contents;
  22.  
  23. for (var i = 0; i < results.length; i++) {
  24. if (results[i].videoPrimaryInfoRenderer) {
  25. var actions = results[i].videoPrimaryInfoRenderer.videoActions.menuRenderer;
  26.  
  27. if (abtnconfig.unsegmentLikeButton) {
  28. if (actions.topLevelButtons[0].segmentedLikeDislikeButtonRenderer) {
  29. var segmented = actions.topLevelButtons[0].segmentedLikeDislikeButtonRenderer;
  30. actions.topLevelButtons.splice(0, 1);
  31. actions.topLevelButtons.unshift(segmented.dislikeButton);
  32. actions.topLevelButtons.unshift(segmented.likeButton);
  33. }
  34. }
  35.  
  36. if (abtnconfig.noFlexibleItems) {
  37. for (var i = 0; i < actions.flexibleItems.length; i++) {
  38. actions.topLevelButtons.push(actions.flexibleItems[i].menuFlexibleItemRenderer.topLevelButton);
  39. }
  40.  
  41. delete actions.flexibleItems
  42. }
  43. }
  44. }
  45.  
  46. var temp = watchFlexy.data;
  47. watchFlexy.data = {};
  48. watchFlexy.data = temp;
  49. }
  50.  
  51. document.addEventListener("yt-page-data-updated", (e) => {
  52. if (e.detail.pageType == "watch") {
  53. updateBtns();
  54. }
  55. });
  56.  
  57. (function() {
  58. ApplyCSS();
  59. function ApplyCSS() {
  60. var styles = document.createElement("style");
  61. styles.innerHTML=`
  62. /* Fix the position of action buttons */
  63. ytd-watch-metadata[modern-metapanel-order] #actions.ytd-watch-metadata {
  64. min-width: auto !important;
  65. }
  66.  
  67. /* Revert classic 'Subscribed' notifcation button */
  68. yt-button-shape.style-scope.ytd-subscribe-button-renderer {
  69. display: flex !important;
  70. }
  71.  
  72. div#notification-preference-button.style-scope.ytd-subscribe-button-renderer > ytd-subscription-notification-toggle-button-renderer-next.style-scope.ytd-subscribe-button-renderer > yt-button-shape > .yt-spec-button-shape-next--size-m {
  73. background-color: transparent !important;
  74. border-radius: 16px !important;
  75. padding-left: 14px !important;
  76. padding-right: 2px !important;
  77. margin-left: 4px !important;
  78. }
  79.  
  80. div#notification-preference-button.style-scope.ytd-subscribe-button-renderer > ytd-subscription-notification-toggle-button-renderer-next.style-scope.ytd-subscribe-button-renderer > yt-button-shape > .yt-spec-button-shape-next--size-m > div.cbox.yt-spec-button-shape-next--button-text-content {
  81. display: none !important;
  82. }
  83.  
  84. div#notification-preference-button.style-scope.ytd-subscribe-button-renderer > ytd-subscription-notification-toggle-button-renderer-next.style-scope.ytd-subscribe-button-renderer > yt-button-shape > .yt-spec-button-shape-next--size-m > div.yt-spec-button-shape-next__secondary-icon {
  85. display: none !important;
  86. }
  87.  
  88. div#notification-preference-button.style-scope.ytd-subscribe-button-renderer > ytd-subscription-notification-toggle-button-renderer-next.style-scope.ytd-subscribe-button-renderer > yt-button-shape > .yt-spec-button-shape-next--size-m {
  89. border-radius: 100px !important;
  90. width: 37px !important;
  91. }
  92.  
  93. yt-smartimation.ytd-subscribe-button-renderer {
  94. display: flex !important;
  95. }
  96.  
  97. /* Make the subscribe button next to the 'Join' button */
  98. #buttons.ytd-c4-tabbed-header-renderer {
  99. flex-direction: row-reverse !important;
  100. }`
  101. document.head.appendChild(styles);
  102. }
  103. })();