Youtube Dark figuccio

youtube dark mode stop riproduzione autom

当前为 2023-10-11 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Youtube Dark figuccio
// @namespace    https://greasyfork.org/users/237458
// @version      8.8
// @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
// @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';
    let timeout;
    let onlytime = true;//barra volume
    let videoElement;
    let audioDivWidth = 0;//larghezza effettiva dell'audio
    let percentage = 0;//percentuale della barra del volume
    let onvolumeBar = false;//Se il mouse si trova sulla barra del volume
    // 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 mostri il suono e la doppia velocità
    const audioDiv = document.createElement("div");
    audioDiv.style.cssText = `
    background-color: rgba(0, 0, 0, 0.5);
    display: inline-block;
    margin-right: 10px;
    color: red;
    font-size: 12px;
    padding: 5px;
    border-radius: 5px;
    font-family: "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    font-weight: bold;
    border:1px solid yellow;
`;


    // Crea un intervallo che mostri il volume del suono
    const volumeSpan = document.createElement("span");
    volumeSpan.style.cursor = "pointer";
    volumeSpan.style.marginLeft = "10px";
    audioDiv.appendChild(volumeSpan);


    //creare barre nere barra sotto il cursore volume
    const volumeBar = document.createElement("span");
    volumeBar.style.cssText = `
        width: 70px;
        height: 10px;
        background-color: rgba(0, 0, 0, 0.5);;
        position: relative;
        cursor: pointer;
        margin-left: 5px;
        display: inline-block;
        padding: 0px 3px;
        border-radius: 5px;
        overflow: hidden;
        border:1px solid red;
    `;
    // Crea una barra del volume bianca/verde
    const volumeIndicator = document.createElement("span");
    volumeIndicator.style.cssText = `height:100%;background-color:green;position:absolute;displayflex;top:0;left:0;`;

    // Aggiungi una barra di visualizzazione del volume alla barra del volume
    volumeBar.appendChild(volumeIndicator);

    // Aggiungi la barra del volume alla pagina
    audioDiv.appendChild(volumeBar);

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

    // Aggiungi a turno gli elementi creati al div contenitore
    containerDiv.appendChild(audioDiv);//volume

    containerDiv.appendChild(timeDiv);//orologio

    // Aggiungi un ascoltatore di eventi per la barra del volume
    volumeBar.addEventListener("mousemove", handleMouseMove);
    volumeBar.addEventListener("click", handleClick);
    volumeBar.addEventListener("mouseleave", handleMouseLeave);

        //area di risposta al click
        timeDiv.onclick = function () {
        onlytime = !onlytime;
        audioDiv.style.display = onlytime ? "inline-block" : "none";
        };


    function initialize() {
        updateSpeedAndVolume();
        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

        updateSpeedAndVolume(); // Aggiornamento in tempo reale delle informazioni su suono e velocità

        setTimeout(updateTime, 200);//Continua ad aggiornare l'ora 1000 /200 ms
    }

    function updateSpeedAndVolume() {
        if (!videoElement) {
            audioDiv.style.display = "none";
        } else {
            const volume = (videoElement.volume * 100).toFixed(0);
            //Determina se è presente una notifica
             audioDiv.style.display = onlytime ? "inline-block" : "none";

            //Determina se attivare una barra bianca
            if (!onvolumeBar) {
                volumeSpan.textContent = `suono: ${volume}%`;
                const currentVolume = videoElement.volume;
                volumeIndicator.style.width = `${currentVolume * 100}%`;
            }
            // Aggiorna audioDivWidth
            audioDivWidth = audioDiv.offsetWidth;
            if (0 == (new Date().getSeconds() % 2)) console.log(audioDivWidth);

        }
    }

    // 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";
        }

    }

    // Funzione di gestione degli eventi quando il mouse si sposta sulla barra del volume
    function handleMouseMove(event) {
        onvolumeBar = true;
        const volumeBarWidth = volumeBar.offsetWidth;
        const mouseX = event.clientX - volumeBar.getBoundingClientRect().left;
        percentage = Math.min(1, Math.max(0, mouseX / volumeBarWidth));
        //la larghezza della barra bianca
        if (percentage * 100 < 5) {
            percentage = 0;
        }
        else if (percentage * 100 > 95) {
            percentage = 1;
        }
        const percentageInt = Math.floor(percentage * 100);
        volumeIndicator.style.width = `${percentage * 100}%`;
        volumeSpan.textContent = `suono: ${percentageInt}%`;

    }

    //Funzione di gestione degli eventi quando il mouse fa clic sulla barra del volume
    function handleClick(event) {
        videoElement.volume = percentage;
    }

    // Gestore eventi quando il mouse lascia la barra del volume
    function handleMouseLeave() {
        onvolumeBar = false;
    }

    // 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);
        }
        updateSpeedAndVolume(); // Aggiorna le informazioni sulla velocità e sul suono
    }

    // 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);
    ///////////////////////
    ///////////////////////////////////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 ottobre 2023///////////////////////////////
setTimeout(function(){document.querySelector("#yDmH0d > c-wiz > div > div > div > div.nYlMgf > div.gOOQJb > div.qqtRac > div.csJmFc > form:nth-child(2) > div > div > button > span").click();}, 1000);
 //rifiuta tutto settembre 2023
setTimeout(function(){document.querySelector("#content > div.body.style-scope.ytd-consent-bump-v2-lightbox > div.eom-buttons.style-scope.ytd-consent-bump-v2-lightbox > div:nth-child(1) > ytd-button-renderer:nth-child(1) > yt-button-shape > button > yt-touch-feedback-shape > div > div.yt-spec-touch-feedback-shape__fill").click();}, 1500);
    //necessario
  if (!document.cookie.match("(^|;)\\s*CONSENT=YES\\+")) {
  document.cookie="CONSENT=YES+;domain=" + window.location.host.match("\.youtube\..+$")[0];
      document.cookie = "PREF=f7=140;domain=youtube.com";//illum cinem disattivata
}
/////////////////////////////////////////////////////////f7 illum cinema
    // document.cookie = "PREF=f6=40000400&f7=140;domain=youtube.com";//ok tema scuro illum cinem disattivata
    ////////////////////////////////////////////////////tema dark sistema
    if (GM_getValue('color-theme')) {
        if (GM_getValue('color-theme') === 'light') {
            document.documentElement.classList.add('dark');
            GM_setValue('color-theme', 'dark');
        } else {
            document.documentElement.classList.remove('dark');
            GM_setValue('color-theme', 'light');
        }
    // se NON impostato in precedenza tramite archiviazione locale
    } else {
        if (document.documentElement.classList.contains('dark')) {
            document.documentElement.classList.remove('dark');
            GM_setValue('color-theme', 'light');
        } else {
            document.documentElement.classList.add('dark');
           GM_setValue('color-theme', 'dark');
        }
    }

    /////////////////////////riproduzione automatica disattivata
    function riproduzioneautomatica () {
    let autoplayButton = document.getElementsByClassName('ytp-autonav-toggle-button')[0];
    if (autoplayButton.getAttribute('aria-checked') === "true") {
       autoplayButton.click();
            }
}
              setInterval(riproduzioneautomatica, 10000);

    /////////////////////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" menu {return;}  {guide_button.click (); } evita errore triangolo giallo
    function minimizeSidebarIfOpened() {
    var guide = document.getElementById('guide');
    var menuButton = document.querySelector('#guide-icon.ytd-masthead');
    if (guide && guide.getAttribute('opened') !== null && menuButton) {
       menuButton.click();
            }
}

        setInterval(minimizeSidebarIfOpened, 1000);
    ///////////////////////////////////////////////////////////
///////////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;}');

//scrollbar nera
(function() {var css = "";
	css += [
		"/*####----BROWSER SCROLL BAR----####*/",
		"::-webkit-scrollbar {",
		"background:#303134!important;",
		"border-left: 1px solid #1A1A1A !important; width:17px!important;",
		"}",
       "::-webkit-scrollbar-thumb {background-color:!important;border-radius:px!important;border:1px solid !important;}",
        ///////////////////pulsanti sotto freccine su e giu
       "::-webkit-scrollbar-button {background-color:#777777;}",
        ///////////////////////freccia nera sopra
       "::-webkit-scrollbar-button:vertical:decrement {",
       "background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAABy6+R8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QgFDgo6IB/FRgAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAc0lEQVQoz+XRoQ2DYBiE4YfUkEDqEfW1TNA5EFUdAM0aTNEpSKqwKAZogkJgmpDUgPkFqFa3py757r1PHP+jEgPqb4ELGizocf0EnHDHO0ALHjhvQ4eNT3BDgSPmcE8RoQ1lOyhHhRgjXpjCtwwdnr864go2lhOp4XYeZgAAAABJRU5ErkJggg==)!important;",
		"background-size: cover!important;",
		"background-repeat: no-repeat!important;",
		"}",
        ////////////////////freccia nera sotto
       "::-webkit-scrollbar-button:vertical:increment {",
       "background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAABy6+R8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QgFDgUlKo/UfAAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAaUlEQVQoz+XPsQmDUAAE0NfHFdI7gZ1kEmdI6Q6WTuEUQiZIl8o0CYGAvYUg3+aXitZ6zcFxx91xbOR44oMO78jfqGdLoQQVekwYEPBHictaW4pHNAeMaHDdmlngFUMtbnv/1fjh7iSYAfRHFgTlUa3mAAAAAElFTkSuQmCC)!important;",
		"background-size: cover!important;",
		"background-repeat: no-repeat!important;",
		"}",
	].join("\n");

if (typeof GM_addStyle != "undefined") {
	GM_addStyle(css);
} else if (typeof PRO_addStyle != "undefined") {
	PRO_addStyle(css);
} else if (typeof addStyle != "undefined") {
	addStyle(css);
} else {
	var node = document.createElement("style");
	node.type = "text/css";
	node.appendChild(document.createTextNode(css));
	var heads = document.getElementsByTagName("head");
	if (heads.length > 0) {
		heads[0].appendChild(node);
	} else {
		// no head yet, stick it whereever
		document.documentElement.appendChild(node);
	}
}
})();
///////////////////////time///////////
var $g = window.jQuery;
var jg = $g.noConflict();
//necessario lasciare la $g
$g(document).ready(function() {
var body=document.body;
var style="position:fixed; top:-1px;margin-left:960px;z-index:99999;"
var box=document.createElement("div");

box.id="mydatatube";
box.style=style;
jg(box).draggable();
body.append(box);

//mostra/nascondi dal menu
function provayo(){
var box = document.getElementById('mydatatube');
box.style.display = ((box.style.display!='none') ? 'none' : 'block');
}
GM_registerMenuCommand("nascondi/mostra time",provayo);
///////////////////////////////////////////////////////////////
   //Imposta lo stile CSS degli elementi nel menu
  GM_addStyle(`
  #setui{width:auto;height:25px; margin-top:2px;margin-left:0px; margin-right:0px;margin-bottom:0px;border-width:1px;}

  input[type="datetime-local"] {background:#3b3b3b;color:lime;border:1px solid yellow; border-radius:5px;margin:0px;text-align:center;}

            `);

setInterval(function(){
let today = new Date();
today.setMinutes(today.getMinutes() - today.getTimezoneOffset());
document.getElementById('tube').value = today.toISOString().slice(0, -1);
}, 70);
 //elemento html nel div readonly datatime non fa comparire licona del calendario
    box.innerHTML=`
                      </p>
                              <fieldset style="background:#3b3b3b; border: 2px solid red;color:lime;border-radius:7px;text-align:center;">
                              <legend>DATA-TIME</legend>
   <div id=setui>

 <input readonly id="tube" type="datetime-local" title="Data-Ora"/>

                                                    </p>
                    </div>
                    </fieldset>
            `;

})();

    /////////
})();