Youtube custom color

Small CSS tweaks to youtube with color theme settings

ของเมื่อวันที่ 21-09-2017 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Youtube custom color
// @description  Small CSS tweaks to youtube with color theme settings
// @include 	 *://*.youtube.com*
// @grant        GM_addStyle
// @grant       GM_getValue
// @grant       GM_setValue
// @run-at document-load
// @version 1.1
// @namespace https://greasyfork.org/users/3167
// ==/UserScript==

var defaultcolor = "hsla(3, 60%, 47%, 1)";

var customcolor = GM_getValue("yt-custom-color", defaultcolor);
GM_setValue('yt-custom-color', customcolor);

GM_addStyle ( "body {\
    /* --yt-custom-color: " + customcolor + "; */\
}");

GM_addStyle ( "#player-ads { display: none; }\
body, ytd-app {\
    --yt-brand-paper-button-color: var(--yt-custom-color) !important;\
    --yt-brand-color: var(--yt-custom-color) !important;\
}\
paper-button.ytd-subscribe-button-renderer {\
    background: var(--yt-custom-color);\
}\
a.yt-simple-endpoint.yt-formatted-string {\
    color: var(--yt-custom-color);\
}\
#progress.ytd-thumbnail-overlay-resume-playback-renderer, .ytp-red2 .ytp-swatch-background-color, .ytp-red2 .ytp-swatch-background-color-secondary, .ytp-play-progress.ytp-swatch-background-color, .ytp-swatch-background-color-secondary {\
    background-color: var(--yt-custom-color);\
}\
path#lozenge-path, #logo path.style-scope.yt-icon {\
    fill: var(--yt-custom-color);\
}\
div#top div#player {\
    max-height: calc(100vh - var(--ytd-masthead-height, 56px));\
}");


unsafeWindow.setcustomcolor = function (colorinput) {
  customcolor = colorinput;
  document.body.style = "--yt-custom-color: " + customcolor + ";";
  GM_setValue('yt-custom-color', customcolor);

  console.log("Changed color theme to : " + customcolor);
}

var customcolorpicker = document.createElement('input');
customcolorpicker.type = "color";
customcolorpicker.onchange = "setcustomcolor(this.value);";
customcolorpicker.style = "display: none;";
customcolorpicker.addEventListener("change", function() {
    unsafeWindow.setcustomcolor(this.value);
});

unsafeWindow.pickcustomcolor = function () {
    customcolorpicker.click();
}

unsafeWindow.resetcustomcolor = function () {
    unsafeWindow.setcustomcolor(defaultcolor);
}

unsafeWindow.setcustomcolor(customcolor);

console.log("Youtube++ loaded!");