Youtube Dark figuccio

youtube dark mode stop riproduzione autom

目前為 2024-02-25 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Youtube Dark figuccio
// @namespace    https://greasyfork.org/users/237458
// @version      11.2
// @description  youtube dark mode stop riproduzione autom
// @author       figuccio
// @match        https://*.youtube.com/*
// @match        https://consent.youtube.com/*
// @run-at       document-end
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @noframes
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @icon         https://www.youtube.com/s/desktop/3748dff5/img/favicon_48.png
// @grant        GM_registerMenuCommand
// @grant        GM_addElement
// @require      http://code.jquery.com/jquery-latest.js
// @require      https://code.jquery.com/ui/1.12.1/jquery-ui.js
// @license      MIT
// ==/UserScript==
(function () {
 'use strict';
    /////////////////////time
    let timeout;
    let videoElement;

    // Crea un div contenitore
    const containerDiv = document.createElement("div");
    containerDiv.style.cssText = `position:fixed;top:10px;right:10px;display:flex;align-items:center;z-index:999999999;`;

    //Crea un div rettangolare arrotondato che visualizza l'ora
    const timeDiv = document.createElement("div");
    timeDiv.title="Data-ora";
    timeDiv.style.cssText = `
    background-color: rgba(0, 0, 0, 0.5);
    color:lime;
    font-size:15px;
    padding: 5px;
    border-radius: 5px;
    cursor: pointer;
    font-family: "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    font-weight: bold;
    border:2px solid green;
`;

    containerDiv.appendChild(timeDiv);//orologio

    function initialize() {
        updateTime();
    }

    function updateTime() {
        findvideo(); // Emette il valore di videoElement
        const now = new Date();
                  //data
        const date = new Date().toLocaleString('it', {'weekday': 'short', 'month': '2-digit', 'day': '2-digit','year':'numeric'});
        /////////////////////ore-minuti-sec-millisec
        const time = new Date().toLocaleTimeString();
        const sss = new Date().getMilliseconds();

        timeDiv.textContent =date +" - "+ time +":"+ sss;//giorno-mese-anno h m s
        setTimeout(updateTime, 200);//Continua ad aggiornare l'ora 1000 /200 ms
    }

    // Scatta nell'angolo in alto a destra del video
    function stickToTopRight() {
        if (videoElement) {
            // Ottieni le informazioni sulle dimensioni e sulla posizione del lettore video
            const videoRect = videoElement.getBoundingClientRect();
            // Imposta la posizione del div contenitore, fissata nell'angolo in alto a destra
            containerDiv.style.top = `${videoRect.top + 10}px`;
            containerDiv.style.right = `${document.documentElement.clientWidth - videoRect.right + 10}px`;
        }
    }

    // Aggiorna la posizione del div contenitore e mantienilo fisso quando la finestra del video viene ridimensionata o viene visualizzata a schermo intero
    function updatePosition() {
        stickToTopRight();
        setTimeout(updatePosition, 500); // Aggiorna la posizione ogni 0,5 secondi 500
    }

    function findvideo() {
        if (window.location.href.includes("www.bilibili.com/video/")) {
            videoElement = document.querySelector("bwp-video");
            if (!videoElement) {
                videoElement = document.querySelector("video");
                if (0 == (new Date().getSeconds() % 2)) console.log("222:" + videoElement);
            }
            else if (0 == (new Date().getSeconds() % 2)) console.log("111:" + videoElement);
        } else {
            videoElement = document.querySelector("video");
            if (0 == (new Date().getSeconds() % 2)) console.log("222:" + videoElement);
        }
        if (null == videoElement) {
            containerDiv.style.display = "none";
        }
        else {
            containerDiv.style.display = "flex";
        }

    }

    // Monitora le modifiche dello stato a schermo intero e aggiungi il div contenitore al livello a schermo intero
    function handleFullscreenChange() {
        if (document.fullscreenElement) {
            // Aggiungi il div contenitore all'elemento a schermo intero quando accedi a schermo intero
            document.fullscreenElement.appendChild(containerDiv);
        } else {
            // Aggiungi nuovamente il div contenitore alla pagina quando esci dalla modalità a schermo intero
            document.body.appendChild(containerDiv);
        }

    }

    // Chiama le funzioni di inizializzazione e aggiornamento della posizione per avviarne l'aggiornamento in tempo reale
    initialize();
    updatePosition();

    // Aggiungi il div contenitore alla pagina
    document.body.appendChild(containerDiv);

    // Ascolta gli eventi di modifica dello stato a schermo intero
    document.addEventListener("fullscreenchange", handleFullscreenChange);
    /////////////////////////////////////////////////////////

    ////////////////////////mostra % volume/////
   let previousVolume = -1;
    function displaySquareVolume() {
        const player = document.getElementById('movie_player');
        const currentVolume = player.getVolume();

        if (currentVolume !== previousVolume) {
            previousVolume = currentVolume;
            const squareVolume = document.querySelectorAll('div[data-layer="4"]');
            squareVolume.forEach((div) => {
                if(div.className === 'ytp-bezel-text-hide') {
                    div.classList.remove('ytp-bezel-text-hide');
                }
                if (div.classList.length === 0) {
                    const ytpBezelTextWrapper = div.querySelector('.ytp-bezel-text-wrapper');
                    ytpBezelTextWrapper.title="Volume";
                    const ytpBezelText = ytpBezelTextWrapper.querySelector('.ytp-bezel-text');
                    const ytpBezel = div.querySelector('.ytp-bezel');
                    div.style.display = 'block';

                    if (ytpBezelText && ytpBezel) {
                        ytpBezelText.innerText = currentVolume + "%";
                        ytpBezel.style.display = 'none';
                    }

                    setTimeout(()=> {
                        div.style.display = 'none';
                    }, 20000);//resta fisso per 20 secondi
                }
            });
        }
    }

    function checkVideoExists() {
        const videoElement = document.querySelector('video');
        if (videoElement) {
            videoElement.addEventListener('volumechange', displaySquareVolume);
            previousVolume = videoElement.volume * 100;
        }
    }

    const observer = new MutationObserver(checkVideoExists);
    const body = document.body;
    const config = {childList: true, subtree: true};
    observer.observe(body, config);
    GM_addStyle('.ytp-bezel-text-wrapper{color:green;cursor:pointer;}');//% volume colore verde
    ///////////////////////
    ///////////////////////////////////volume predefinito 70%
    if (GM_getValue('Default_Volume') === undefined) //Se Default_Volume non è stato ancora impostato
  { //Starts the if condition
    GM_setValue('Default_Volume', 70); //Salva il volume predefinito al 70%
  } //Finishes the if condition

window.sessionStorage.setItem('yt-player-volume', '{"data":"{\\"volume\\":' + GM_getValue('Default_Volume') + ',\\"muted\\":false}","creation":' + new Date().valueOf() + '}'); //Imposta il volume YT predefinito

    //nuovo accetta cookie consent prima di continuare dicembre 2023
 if (!document.cookie.match("(^|;)\\s*CONSENT=YES\\+")) {
document.cookie ="SOCS=CAISEwgDEgk2MDkwMDAzMTIaAml0IAEaBgiA4-SuBg;max-age=315360000";//febbraio 2024 accetta tutto
document.cookie ="CONSENT=YES+;domain=.youtube.com;max-age=315360000";
document.cookie ="PREF=f6=40000400&f7=140;domain=youtube.com";//ok tema scuro illum cinem disattivata
location.reload();
}
    /////////////////////////riproduzione automatica disattivata
    document.addEventListener('yt-navigate-finish', () => {
  /* Qualsiasi codice riportato di seguito verrà eseguito solo sulle pagine www.youtube.com/watch?v */
     if (!window.location.href.includes("watch")) return;
     var i = window.setInterval(() => {
     const t = document.getElementsByClassName('ytp-autonav-toggle-button')[0];
     if (t.getAttribute('aria-checked') === "true") {
        t.click();

      clearInterval(i);
    } else if (t.getAttribute('aria-checked') === "true") {
      t.click();
    }
  }, 1000);
})
 /////////////////////barra volume video sempre visibile
    GM_addStyle('.ytp-volume-panel {width:52px!important;}');
    GM_addStyle('.ytp-volume-slider-handle:before {background:green!important;}');//linea volume verde
    GM_addStyle('.ytp-volume-slider-handle {background:red!important;}');//pallino volume

    //////////////////////////////////
                  //shorts e tendenze
GM_addStyle('#dismissible.ytd-rich-shelf-renderer {display:none!important;}');
//Rimuovi Youtube Commenti
GM_addStyle('ytd-comments.style-scope{ display:none !important;}');
//adblock grosso banner youtube premium
GM_addStyle(`#masthead-ad { display:none!important;}`);

//promemoria privacy
document.cookie = "HideTicker=true;domain=.youtube.com;max-age=315360000";
//annotazioni video
GM_addStyle(`.html5-video-player .ytp-cards-button{display:none!important;}`);
//popup non hai eseguito laccesso
GM_addStyle(`yt-tooltip-renderer{display:none!important;}`);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
    //hide guide local storage
    (function () {
    'use strict';

    let guide = ['Default', 'Compact', 'Compact-E'];
    let guideMode = GM_getValue('guide', 2);
    let p = 'ytd-app[guide-persistent-and-visible]';
    let m = 'ytd-app[mini-guide-visible]';
    let i = '!important';

    function setStyle() {
        const guideEL = document.querySelector('[guideStyle]');
        if (guideEL) guideEL.remove();
        guideMode = GM_getValue('guide', 2);
        switch (guideMode) {
        case 1:
        GM_addElement(document.documentElement, 'style', {
        textContent: `${p} tp-yt-app-drawer {display: none${i};}${p} tp-yt-app-header {left: 72px${i};}${p} #channel-container {max-height: 218px${i};}${p} ytd-page-manager {margin-left: var(--ytd-mini-guide-width)${i};}${p} ytd-mini-guide-renderer {display: unset${i};}${p} ytd-playlist-header-renderer.ytd-browse {left: var(--ytd-mini-guide-width)${i};}${m} tp-yt-app-drawer {display: unset ${i};visibility: visible ${i};}${m} tp-yt-app-header {left: 240px ${i};}${m} #channel-container {max-height: 230px;}${m} ytd-page-manager {margin-left: var(--app-drawer-width) ${i};}${m} ytd-mini-guide-renderer {display: none ${i};}${m} #scrim.tp-yt-app-drawer {opacity: 1 ${i};}${m} #contentContainer.tp-yt-app-drawer {transform: translate3d(0, 0, 0) ${i};}${m} #contentContainer.tp-yt-app-drawer #header.ytd-app {display: none ${i};}${m} ytd-playlist-header-renderer.ytd-browse {left: var(--app-drawer-width) ${i};}`,
        guideStyle: 'Compact',
                });
                break;
        case 2:
    GM_addElement(document.documentElement, 'style', {
    textContent: `${p} tp-yt-app-drawer {display: none${i};}${p} tp-yt-app-header {left: 72px${i};}${p} #channel-container {max-height: 218px${i};}${p} ytd-page-manager {margin-left: var(--ytd-mini-guide-width)${i};}${p} ytd-mini-guide-renderer {display: unset${i};}${p} ytd-playlist-header-renderer.ytd-browse {left: var(--ytd-mini-guide-width)${i};}${m} tp-yt-app-drawer {display: unset ${i};visibility: visible ${i};}${m} tp-yt-app-header {left: 240px ${i};}${m} #channel-container {max-height: 230px;}${m} ytd-page-manager {margin-left: var(--app-drawer-width) ${i};}${m} ytd-mini-guide-renderer {display: none ${i};}${m} #scrim.tp-yt-app-drawer {opacity: 1 ${i};}${m} #contentContainer.tp-yt-app-drawer {transform: translate3d(0, 0, 0) ${i};}${m} #contentContainer.tp-yt-app-drawer #header.ytd-app {display: none ${i};}${m} ytd-playlist-header-renderer.ytd-browse {left: var(--app-drawer-width) ${i};}`,
    guideStyle: 'Compact-E',
                });
                break;
        }
    }
    setStyle();

    function changeStyle() {
        if (guideMode < 2) {
            GM_setValue('guide', guideMode + 1);
        } else {
            GM_setValue('guide', (guideMode = 0));
        }

        setStyle();
        GM_registerMenuCommand(`Guide style: ${guide[guideMode]}`, changeStyle, {
            title: 'Fare clic per selezionare successivo',
            autoClose: false,
            id: guideCommand,
        });
    }

    const guideCommand = GM_registerMenuCommand(`Guide style: ${guide[guideMode]}`, changeStyle, {
        title: 'Fare clic per selezionare successivo',
        autoClose: false,
    });
})();

///////////rimuove scritta consigliati allinterno video
GM_addStyle('.ytp-cards-teaser-label{display:none !important;}');
///////////icome home ecc e titoli home tendenze ecc
GM_addStyle('.title,.pieSegment,svg {color:#5f84f1 !important;}');
//scrittura verde
GM_addStyle('.aplos-donut-center-content,.formatted-percentage.yta-explore-table-row,.entity-name.ytcp-navigation-drawer,#tags-count,h3.ytcp-uploads-basics,.source.ytpp-self-certification-predictor span.ytpp-self-certification-predictor,.m10n-icon-section.ytpp-self-certification-predictor span.ytpp-self-certification-predictor,#unplayableText,.content-title,.progress-label.ytcp-video-upload-progress,.issue-text.ytcd-help-center-issues-item,#campaign-title.ytd-donation-shelf-renderer,#published-time,.paddingten,#ctr-title,.label,#keywords-description,.channel-name,#purchase-amount,.paper-input-char-counter,.likes-label,#subtitle,.yt-multi-page-menu-section-renderer,.published-time-text,.yta-table-card,.ytcp-trend-label,.metric-value-absolute,#title-placeholder,#toggle.ytd-grid-renderer,#vote-count-middle,.ytcp-omnisearch,.ytcp-table-header,#vote-count-left,#subscribers,#guide-section-title,.content-text,#embed-label,#upnext,.count-text,.ytd-channel-about-metadata-renderer,#title,#subscriber-count,#byline,#content,.view-count,.yt-simple-endpoint,#account-name {color:green!important;}');

//////////////play avanti ingrandisci colore rosso
GM_addStyle('path[class=\"ytp-svg-fill\"] { fill: red !important;}');
//volume verde
GM_addStyle('path[class=\"ytp-svg-fill ytp-svg-volume-animation-speaker\"] { fill: green !important;}');

//ingranaggio impostazioni
GM_addStyle('path[d=\"m 23.94,18.78 c .03,-0.25 .05,-0.51 .05,-0.78 0,-0.27 -0.02,-0.52 -0.05,-0.78 l 1.68,-1.32 c .15,-0.12 .19,-0.33 .09,-0.51 l -1.6,-2.76 c -0.09,-0.17 -0.31,-0.24 -0.48,-0.17 l -1.99,.8 c -0.41,-0.32 -0.86,-0.58 -1.35,-0.78 l -0.30,-2.12 c -0.02,-0.19 -0.19,-0.33 -0.39,-0.33 l -3.2,0 c -0.2,0 -0.36,.14 -0.39,.33 l -0.30,2.12 c -0.48,.2 -0.93,.47 -1.35,.78 l -1.99,-0.8 c -0.18,-0.07 -0.39,0 -0.48,.17 l -1.6,2.76 c -0.10,.17 -0.05,.39 .09,.51 l 1.68,1.32 c -0.03,.25 -0.05,.52 -0.05,.78 0,.26 .02,.52 .05,.78 l -1.68,1.32 c -0.15,.12 -0.19,.33 -0.09,.51 l 1.6,2.76 c .09,.17 .31,.24 .48,.17 l 1.99,-0.8 c .41,.32 .86,.58 1.35,.78 l .30,2.12 c .02,.19 .19,.33 .39,.33 l 3.2,0 c .2,0 .36,-0.14 .39,-0.33 l .30,-2.12 c .48,-0.2 .93,-0.47 1.35,-0.78 l 1.99,.8 c .18,.07 .39,0 .48,-0.17 l 1.6,-2.76 c .09,-0.17 .05,-0.39 -0.09,-0.51 l -1.68,-1.32 0,0 z m -5.94,2.01 c -1.54,0 -2.8,-1.25 -2.8,-2.8 0,-1.54 1.25,-2.8 2.8,-2.8 1.54,0 2.8,1.25 2.8,2.8 0,1.54 -1.25,2.8 -2.8,2.8 l 0,0 z\"] {fill:#33d79e !important;}');
//mini player
GM_addStyle('path[d=\"M25,17 L17,17 L17,23 L25,23 L25,17 L25,17 Z M29,25 L29,10.98 C29,9.88 28.1,9 27,9 L9,9 C7.9,9 7,9.88 7,10.98 L7,25 C7,26.1 7.9,27 9,27 L27,27 C28.1,27 29,26.1 29,25 L29,25 Z M27,25.02 L9,25.02 L9,10.97 L27,10.97 L27,25.02 L27,25.02 Z\"] {fill:#33d79e  !important;}');
//modalita cinema
GM_addStyle('path[d=\"m 28,11 0,14 -20,0 0,-14 z m -18,2 16,0 0,10 -16,0 0,-10 z\"] { fill:#33d79e !important;}');
////////////////////////////covid
GM_addStyle('ytd-compact-promoted-item-renderer[view-style=COMPACT_PROMOTED_ITEM_STYLE_RICH_GRID] #dismissible.ytd-compact-promoted-item-renderer{display:none !important;}');
///////////////////time
    GM_addStyle('.ytp-time-display{color:lime!important;background:transparent!important;font-size:14px!important;}');
    let bar = document.getElementsByClassName("style-scope ytd-searchbox")[0];
    let clock = document.createElement("span");
    clock.classList.add("ytp-time-display");
    clock.innerText = "Toto";
    clock.title="Time";

    function clockTime() {
        var today = new Date();
        const time = new Date().toLocaleTimeString();
        var milli = today.getMilliseconds()
        clock.innerText =time+ ":" +milli;;
        setTimeout(clockTime, 70);
    }
    clockTime();
    bar.insertBefore(clock, bar.childNodes[0]);
    //////////////////////////
})();