Youtube custom color

Small CSS tweaks to youtube with color theme settings

Versione datata 21/09/2017. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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!");