Youtube Button Remover

Remove buttons

Verze ze dne 24. 04. 2022. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        Youtube Button Remover
// @namespace   LeKAKiD
// @match       https://*/*
// @grant       GM_getValue
// @grant       GM_setValue
// @grant       GM_registerMenuCommand
// @version     1.4
// @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();

const frames = [...document.querySelectorAll('iframe')];

if(frames.some(e => urlRegex.test(e.src))) {
  Object.keys(defaultConfig).forEach(key => {
    GM_registerMenuCommand(ytButtons[key].label, () => {
      currentConfig[key] = !currentConfig[key];
      GM_setValue('config', currentConfig);
      if(urlRegex.test(location.href)) setStyle();
    });
  });
}
else {
  GM_registerMenuCommand('확인된 유튜브 영상 없음');
}