- // ==UserScript==
- // @name Youtube Dark figuccio
- // @namespace https://greasyfork.org/users/237458
- // @version 2.6
- // @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==
- //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; }');
- ///////////////////////////////////////////////////////////////////////////clock
- $(document).ready(function() {
- (function() {
- 'use strict';
- GM_addStyle('.ytp-time-display {color:!important;}');
- 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();
- var milli = today.getMilliseconds()
- if (h < 10) h = "0" + h;
- if (m < 10) m = "0" + m;
- if (s < 10) s = "0" + s;
- clock.innerText = h + ":" + m + ":" + s+ ":" +milli;
- setTimeout(clockTime, 70);
- }
- 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("中文(简体)")
- //chiude impostazioni
- $('.ytp-settings-button').click()
- }
- $('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)
- })()
-
- ///////////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;}');
- //scrollbar nera
- (function() {var css = "";
- css += [
- "/*####----BROWSER SCROLL BAR----####*/",
- "::-webkit-scrollbar {",
- "background: -webkit-linear-gradient(40deg , #040404 , #0C0C0C , #040404 100%)!important;",
- "border-left: 1px solid #1A1A1A !important;",
- "}",
- "::-webkit-scrollbar-thumb {background-color: #272727!important;border-radius: 16px!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);
- }
- }
- })();
-