Action Buttons Fix (modified)

Fixes watch action buttons to be like how they used to be!

当前为 2023-05-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Action Buttons Fix (modified)
  3. // @version 1.0.0
  4. // @description Fixes watch action buttons to be like how they used to be!
  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. ytd-watch-metadata[modern-metapanel-order] #actions.ytd-watch-metadata {
  63. min-width: auto !important;
  64. }`
  65. document.head.appendChild(styles);
  66. }
  67. })();