Youtube Button Remover

Remove buttons

目前為 2022-04-22 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Youtube Button Remover
// @namespace   LeKAKiD
// @match       https://*/*
// @grant       GM_getValue
// @grant       GM_setValue
// @grant       GM_registerMenuCommand
// @version     1.3
// @author      LeKAKiD
// @description Remove buttons
// @license     MIT
// ==/UserScript==

const ytButtons = {
  next: {
    label: '1 다음 재생 버튼',
    style: `
      a.ytp-next-button {
        display: none !important;
      }
    `,
  },
  autonav: {
    label: '2 자동 재생 버튼',
    style: `
      [data-tooltip-target-id="ytp-autonav-toggle-button"] {
        display: none !important;
      }
    `,
  },
  subtitle: {
    label: '3 사용 불가 자막 버튼',
    style: `
      .ytp-subtitles-button:not([title$="(c)"]):not(:hover) {
        display: none !important;
      }
    `,
  },
  youtube: {
    label: '4 유튜브에서 보기 버튼',
    style: `
      .ytp-youtube-button {
        display: none !important;
      }
    `,
  },
  miniplayer: {
    label: '5 미니 플레이어 버튼',
    style: `
      .ytp-miniplayer-button {
        display: none !important;
      }
    `,
  },
  theater: {
    label: '6 극장 모드 버튼',
    style: `
      .ytp-size-button {
        display: none !important;
      }
    `,
  },
}

const defaultConfig = {
  next: true,
  autonav: true,
  subtitle: false,
  youtube: false,
  miniplayer: true,
  theater: true,
}

const currentConfig = {
  ...defaultConfig,
  ...GM_getValue('config', undefined),
}

const styleElement = document.createElement('style');
document.head.append(styleElement);

function setStyle() {
  const configEntries = Object.entries(currentConfig);
  const style = configEntries.reduce((prev, [key, value]) => prev + (!value ? ytButtons[key].style : ''), '');
  styleElement.textContent = style;
}

const urlRegex = /https:\/\/(www\.){0,1}youtube\.com\/($|(|watch|embed).*)/;
if(urlRegex.test(location.href)) setStyle();

Object.keys(defaultConfig).forEach(key => {
  GM_registerMenuCommand(ytButtons[key].label, () => {
    currentConfig[key] = !currentConfig[key];
    GM_setValue('config', currentConfig);
    if(urlRegex.test(location.href)) setStyle();
  })
});