Greasy Fork is available in English.

Youtube Dark figuccio

youtube dark mode stop riproduzione autom

07.02.2021 itibariyledir. En son verisyonu görün.

// ==UserScript==
// @name         Youtube Dark figuccio
// @namespace    https://greasyfork.org/users/237458
// @version      2.2
// @description  youtube dark mode stop riproduzione autom
// @author       figuccio
// @match        https://*.youtube.com/*
// @run-at       document-start
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @noframes
// @require     https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// ==/UserScript==
///////////////////////////////////////////////////comandi video colorati sempre visibili
/*
(function() {
	//passa il mouse sui controlli per aggiornarli (questo sembra funzionare anche con 2000 ms invece di 1000 ms)
	var evObj = document.createEvent('Events');
	evObj.initEvent("mousemove", true, false);
	var moviePlayer = document.getElementById("movie_player");
    setInterval(function() { moviePlayer = moviePlayer || document.getElementById("movie_player"); moviePlayer.dispatchEvent(evObj); }, 1000);
	var css = document.createElement('style');
    css.type = "text/css";
    css.textContent = [
".ytp-chrome-bottom {opacity: 1!important;background:green none repeat scroll 0% 0%!important; width: 100%!important; left: 0!important;}", //hanno controlli sempre visibili, con il vecchio colore, e occupano l'intera larghezza
	].join("\n");
    document.head.appendChild(css);
})();
*/

//////////////////////////////////////
  //f5=20000 autoplay on    f5=30000 autoplay off
document.cookie = "PREF=f1=50000000&f5=30000&f6=400; domain=.youtube.com;max-age=315360000";

//////////////////////////////
//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; }`);
//////////////////// hide "guide" menu
$(document).ready(function() {
(function() {
	var guide_button=document.getElementById('guide-button');
	if(guide_button){
		var tmp=guide_button.getElementsByTagName('button');
        if(tmp.length) {
			tmp=tmp[0].attributes;
			if(tmp&&tmp['aria-pressed'].value=='true')
				guide_button.click();
		    }
	    }
})();

});

//youtube stai zitto
(function(){
"use strict";
function consent() {
  var e=document.querySelector('#introAgreeButton');
  e && e.click();
  }
if (location.href.startsWith('https://consent.youtube.com/')) {
  if (document.readyState != 'loading') consent();
  else document.addEventListener('DOMContentLoaded', consent);
  return;
  }

function cookies() {
  var r={}, a=document.cookie;
  a.split(';').forEach(function(e){
    var p=e.split('=');
    if (p[0]) r[p.shift().trim()]=p.join('=');
    });
  return r;
  }

var ck=cookies();
if (ck['APISID']) return;

function SImutF(mutL){
  for (let mut of mutL) {
    var t=mut.target;
    if ( (t.id=='dismiss-button') || (t.parentNode && (t.parentNode.id=='dismiss-button')) ) {
      if (t.classList.contains('yt-upsell-dialog-renderer') || t.classList.contains('ytd-mealbar-promo-renderer')) ;
      else if (t.classList.contains('yt-tooltip-renderer')) {
        t=t.querySelector('yt-button-renderer');
        if (!t) continue;
        }
      else continue;
      setTimeout(function(){t.click()}, 300);
      subObs.observe(t,{attributes: true, subtree: true});
      return;
      }
    }
  }
var obs=new MutationObserver(SImutF);
var subObs=new MutationObserver(SImutF);
var obs2=new MutationObserver(function(mutL){
  for (let mut of mutL) {
    for (let n of mut.addedNodes) {
      if (n.nodeName == 'YTD-POPUP-CONTAINER') {
        this.disconnect();
        setObs();
        return;
        }
      }
    }
  });
var obs3=new MutationObserver(function(mutL){
  for (let mut of mutL) {
    for (let n of mut.addedNodes) {
      if (n.nodeName == 'YTD-CONSENT-BUMP-LIGHTBOX') {
        this.disconnect();
        setTimeout(function(){
          let ck=cookies();
          if (ck['CONSENT'] && !ck['CONSENT'].startsWith('YES')) document.cookie='CONSENT=YES+;path=/;secure;domain=youtube.com;expires='+(new Date(Date.now()+567648000000)).toUTCString()+';';
          }, 5000);
        return;
        }
      }
    }
  });

function init() {
  var t;
  if (document.querySelector('ytm-app')) {
    new MutationObserver(function(mutL){
      for (let mut of mutL) {
        for (let n of mut.addedNodes) {
          if (n.classList.contains('upsell-dialog-lightbox') || n.classList.contains('consent-bump-lightbox') ) {
            if (t=document.querySelector('.upsell-dialog-dismiss-button button, .consent-bump-button-wrapper button')) {
              t.click();
              }
            }
          }
        }
      }).observe(document.body, {childList: true, subtree: false});
    }

  setObs();
  if (ck['CONSENT'] && !ck['CONSENT'].startsWith('YES')) {
    obs3.observe(document.body, {childList:true});
    setTimeout(function(){obs3.disconnect();},30000);
    }
  }

var c=1;
function setObs(){
  var r=document.querySelector('ytd-app ytd-popup-container');
  if (!r) {
    if (c--) obs2.observe(document.querySelector('ytd-app'), {childList:true});
    return;
    }
  obs.observe(r, {childList: true, subtree: true});
  }
if (document.readyState != 'loading') init();
else document.addEventListener('DOMContentLoaded', init);

var s=document.createElement('style');
(document.head || document.documentElement).appendChild(s);
s.textContent="#consent-bump,iron-overlay-backdrop,yt-upsell-dialog-renderer{opacity:0;}yt-upsell-dialog-renderer *,yt-bubble-hint-renderer,.upsell-dialog-lightbox,.consent-bump-lightbox{display:none !important;}ytd-app > ytd-consent-bump-lightbox,ytd-app ~ iron-overlay-backdrop{display:none;}";

s=document.createElement('script');
s.textContent= `(function(){var c=80, pl, plR, oldp={};
  function f(){
    plR=document.querySelector('ytd-player#ytd-player');
    if (plR) pl=plR.getPlayer();
    if (!pl) {
      if (--c) setTimeout(f,200);
      else if (plR) {
        var obs=new MutationObserver(function(mutL){
          for (let mut of mutL) {
            for (let n of mut.addedNodes) {
              if (n.id == 'movie_player') {
                this.disconnect();
                pl=plR.getPlayer();
                init();
                return;
                }
              }
            }
          }).observe(document.querySelector('ytd-app'), {childList: true, subtree: true});
        }
      return;
      }
    else init();
    }
  if (document.readyState != 'loading') f();
  else document.addEventListener('DOMContentLoaded', f);

  function init() {
    for (let i in pl) if (typeof pl[i] == 'function') {
      if ( !['cancelPlayback', 'pauseVideo', 'stopVideo', 'playVideo'].includes(i) ) continue;
      oldp[i]=pl[i];
      pl[i]=function() {
        let st=(new Error()).stack;
        if ( (st.search(/(\\.onFulfilled|scheduler\\.js:|handlePopupClose_)/)>0) && (st.search(/onYtStopOldPlayer_/) ==-1) ) return;
        oldp[i].apply(this,arguments);
        }
      }
    }
  })();`;

(document.head || document.documentElement).appendChild(s);
if (s.parentNode) s.parentNode.removeChild(s);
})();

///////////////////////////////////////////////////////////////////////////
GM_addStyle('#country-code::after{content: " yuotube Dark figuccio" }');
GM_addStyle('#country-code.ytd-topbar-logo-renderer {color:red!important; }');
///////////////////////////////////////////////////////////////////////////
$(document).ready(function() {
(function() {
    'use strict';
    let bar = document.getElementsByClassName("ytp-right-controls")[0];
    let clock = document.createElement("span");
    clock.classList.add("ytp-time-display");
    clock.innerText = "Toto";
    function clockTime() {
        var today = new Date();
        var h = today.getHours();
        var m = today.getMinutes();
        var s = today.getSeconds();
        if (h < 10) h = "0" + h;
        if (m < 10) m = "0" + m;
        if (s < 10) s = "0" + s;
        clock.innerText = h + ":" + m + ":" + s;
        setTimeout(clockTime, 500);
    }
    clockTime();
    bar.insertBefore(clock, bar.childNodes[0]);
})();
    });
////////////////////////////////ricarica da solo youtube cosi lorologio si vede sempre
function redirect_yt() {
    if (!window.location.hash) {
      if (document.location.toString().indexOf("watch?v=") != -1) {
        window.location.replace(window.location.href+"#fix");
      }
    }
}

var url = document.location.toString();
document.querySelector('html').addEventListener('DOMNodeInserted', function(ev){
  var new_url = document.location.toString();
  if (url == new_url) return; //già controllato o elaborato
  url = new_url;

  redirect_yt() // eseguito quando l'URL cambia
});

setTimeout(() => { redirect_yt(); }, 1000);

//rimuove publicita video
const host_url = location.host;

if (host_url === "www.youtube.com") {
    setInterval(
        function () {
            try {
                const elem1 = document.getElementsByClassName("ytp-ad-overlay-close-container");
                elem1[0].click();
            } catch (e) {
                ;
            }
            try {
                const elem2 = document.getElementsByClassName("ytp-ad-skip-button-container");
                elem2[0].click();
            } catch (e) {
                ;
            }
        }, 1000
    )
}

///////////rimuove scritta consigliati allinterno video
GM_addStyle('.ytp-cards-teaser-label{ display:none !important; }');
///////////traduci//////////////
(() => {
    const translate = () => {
        const onLoadStart = () => {
            const clickActive = (clickBtn, role = "menuitemradio") => {
                const theNode = $(`[role=${role}]:contains(${clickBtn})`)
                theNode.length ? theNode.click() : ''
            }
            const ccBtnT = $('.ytp-subtitles-button[aria-pressed="true"][style=""]')
            const ccBtnF = $('.ytp-subtitles-button[aria-pressed="false"][style=""]')
            if (!(ccBtnT.length + ccBtnF.length)) return
            ccBtnF.click()
            $('.ytp-settings-button').click()
            clickActive("字幕", "menuitem")
            clickActive("中文(简体)")
            clickActive("中文(中国)")
            clickActive("自动翻译")
            clickActive("中文(简体)")
        }
        $('video').on('loadstart', onLoadStart).trigger('loadstart')
    }
    translate()
    const intervalNum = setInterval(()=>{
        const videoNode = document.querySelector('video')
        if (videoNode) {
            videoNode.addEventListener('resize', () => { console.log('resize');translate() },{once:true})
            clearInterval(intervalNum)
        }
    },500)
})()