Youtube Button Remover

Remove buttons

当前为 2022-04-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Youtube Button Remover
  3. // @namespace LeKAKiD
  4. // @match https://*/*
  5. // @grant GM_getValue
  6. // @grant GM_setValue
  7. // @grant GM_registerMenuCommand
  8. // @version 1.5
  9. // @author LeKAKiD
  10. // @description Remove buttons
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. const ytButtons = {
  15. next: {
  16. label: '1 다음 재생 버튼',
  17. style: `
  18. a.ytp-next-button {
  19. display: none !important;
  20. }
  21. `,
  22. },
  23. autonav: {
  24. label: '2 자동 재생 버튼',
  25. style: `
  26. [data-tooltip-target-id="ytp-autonav-toggle-button"] {
  27. display: none !important;
  28. }
  29. `,
  30. },
  31. subtitle: {
  32. label: '3 사용 불가 자막 버튼',
  33. style: `
  34. .ytp-subtitles-button:not([title$="(c)"]):not(:hover) {
  35. display: none !important;
  36. }
  37. `,
  38. },
  39. youtube: {
  40. label: '4 유튜브에서 보기 버튼',
  41. style: `
  42. .ytp-youtube-button {
  43. display: none !important;
  44. }
  45. `,
  46. },
  47. miniplayer: {
  48. label: '5 미니 플레이어 버튼',
  49. style: `
  50. .ytp-miniplayer-button {
  51. display: none !important;
  52. }
  53. `,
  54. },
  55. theater: {
  56. label: '6 극장 모드 버튼',
  57. style: `
  58. .ytp-size-button {
  59. display: none !important;
  60. }
  61. `,
  62. },
  63. }
  64.  
  65. const defaultConfig = {
  66. next: true,
  67. autonav: true,
  68. subtitle: false,
  69. youtube: false,
  70. miniplayer: true,
  71. theater: true,
  72. }
  73.  
  74. const currentConfig = {
  75. ...defaultConfig,
  76. ...GM_getValue('config', undefined),
  77. }
  78.  
  79. const styleElement = document.createElement('style');
  80. document.head.append(styleElement);
  81.  
  82. function setStyle() {
  83. const configEntries = Object.entries(currentConfig);
  84. const style = configEntries.reduce((prev, [key, value]) => prev + (!value ? ytButtons[key].style : ''), '');
  85. styleElement.textContent = style;
  86. }
  87.  
  88. const urlRegex = /https:\/\/(www\.){0,1}youtube\.com\/($|(|watch|embed).*)/;
  89. if(urlRegex.test(location.href)) setStyle();
  90.  
  91. Object.keys(defaultConfig).forEach(key => {
  92. GM_registerMenuCommand(ytButtons[key].label, () => {
  93. currentConfig[key] = !currentConfig[key];
  94. GM_setValue('config', currentConfig);
  95. if(urlRegex.test(location.href)) setStyle();
  96. });
  97. });