Remove buttons
当前为
// ==UserScript==
// @name Youtube Button Remover
// @namespace LeKAKiD
// @match https://*/*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_registerMenuCommand
// @version 1.0
// @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)"]) {
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];
setStyle();
GM_setValue('config', currentConfig);
})
});