// ==UserScript==
// @name Youtube Dark figuccio
// @namespace https://greasyfork.org/users/237458
// @version 3.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==
// hide "guide" menu adesso se clicco sul pulsante youtube per tornare alla home il menu rimane chiuso
(function () {
'use strict';
// testare prima la disponibilità dell'archiviazione locale e caricare le impostazioni da lì
let settings, ls, saver;
try {
function lsTest (st, v) {
st.setItem ('__fix_test__', v);
return st.getItem ('__fix_test__') == v;
};
let _s = window.localStorage;
if (lsTest (_s, 'qwe') && lsTest (_s, 'rty')) { // fare 2 volte solo nel caso in cui LS abbia memorizzato il valore una volta, ma non consente di modificarlo in seguito
ls = _s;
ls.removeItem ('__fix_test__');
settings = JSON.parse (ls.getItem ('__fix__settings__'));
}
}
catch (e) { }
// seleziona archiviazione: GM _ * / GM. * o archiviazione locale (nel caso in cui il gestore degli script utente non ci conceda GM)
if (typeof (GM_getValue) !== 'undefined' && typeof (GM_setValue) !== 'undefined' && GM_getValue && GM_setValue) {
saver = function () {
GM_setValue ('settings', settings);
if (ls)
ls.removeItem ('__fix__settings__');
}
if (!settings)
settings = GM_getValue ('settings', {});
else
saver ();
settings.storage = 'GM_*Value';
}
else if (typeof (GM) !== 'undefined' && GM && GM.getValue && GM.setValue) {
saver = function () {
(async () => await GM.setValue ('settings', settings)) ();
if (ls)
ls.removeItem ('__fix__settings__');
};
if (!settings)
settings = (async () => await GM.getValue ('settings', {})) ();
else
saver ();
settings.storage = 'GM.*Value';
}
else if (ls) {
if (!settings)
settings = {};
saver = function () {
ls.setItem ('__fix__settings__', JSON.stringify (settings));
};
settings.storage = 'window.localStorage.*Item';
}
else
settings = {};
// imposta i valori predefiniti
//settings.version = fix_version;
if (!("hide_guide" in settings))
settings.hide_guide = true;
if (document.location.pathname == '/fix-settings') {
let back = document.createElement ('div');
back.className = 'ytfixback';
let plane = document.createElement ('div'), e1, e2;
plane.className = 'ytfix';
if (!("no_resume_time" in settings))
settings.no_resume_time = false;
console.log ('fix settings:', settings);
// cattura la pagina "impostazioni"
let style = document.createElement ('style');
style.type = 'text/css';
style.innerHTML = [
].join ('');
e1 = document.createElement ('b');
e1.appendChild (document.createTextNode ('YouTube Polymer Fixes: Settings'));
AddLine (e1);
if (!saver) {
e1 = document.createElement ('span');
e1.appendChild (document.createTextNode ('Cannot edit settings: no access to any storage.'));
AddLine (e1);
e1 = document.createElement ('span');
e1.appendChild (document.createTextNode ('If you are using Firefox, allow cookies for this site.'));
AddLine (e1);
}
else {
let ess = {};
e2 = document.createElement ('input');
e2.type = 'button';
e2.className = 'ytfix_button';
e2.value = 'Return to YouTube without saving';
e2.addEventListener ('click', function () {
history.back ();
});
AddLine (e1, e2);
}
let int = setInterval (function () {
if (!document.body)
return;
document.body.appendChild (back);
document.body.appendChild (plane);
clearInterval (int);
}, 1);
console.log ('Settings page created');
return;
}
// applica le impostazioni
let styles = [], inject_func = [], inject_ints = [];
if (settings.hide_guide) {
function HideGuideTimer (info) {
if (info.act == 0) { // observe location change
let url = document.location.toString ();
if (url != info.url)
info.act = 1;
}
if (info.act == 1) { // attendere il completamento del caricamento della pagina di sorp
let Q = document.getElementsByTagName ('yt-page-navigation-progress');
if (!Q.length)
return;
if (Q [0].hasAttribute ('hidden'))
info.act = 2;
}
if (info.act == 2) { // attendere il pulsante e premerlo se necessario
let guide_button = document.getElementById ('guide-button');
if (!guide_button)
return;
let tmp = guide_button.getElementsByTagName ('button');
if (!tmp.length)
return;
tmp = tmp [0];
if (!tmp.hasAttribute ('aria-pressed'))
return;
if (tmp.attributes ['aria-pressed'].value == 'true')
guide_button.click ();
else {
info.url = document.location.toString ();
info.act = 0;
window.dispatchEvent (new Event ('resize'));
}
}
}
inject_func.push (HideGuideTimer);
inject_ints.push ({ call: HideGuideTimer, params: [{ act: 2 }] });
}
// pulsante "impostazioni"
// Impossibile memorizzare il pulsante creato: Polymer sostituisce il suo contenuto durante il soft reload lasciando i tag al loro posto
// ma può memorizzare elementi che Polymer non sa come trattare e che rilascia
function AddStyles () {
if (styles.length == 0)
return;
if (!document.head)
return setTimeout (AddStyles, 1);
let style_element = document.createElement ('style');
style_element.type = 'text/css';
style_element.innerHTML = styles.join ('');
document.head.appendChild (style_element);
}
AddStyles ();
// injection
function InjectInterval () {
for (let i = ints.length; --i >= 0; ) {
const Q = ints [i];
try { Q.call.apply (this, Q.params); }
catch (e) { }
}
}
let ss = ['(function () {'];
for (let i = inject_func.length; --i >= 0; )
ss.push (inject_func [i].toString ());
ss.push ('let ints = [');
for (let i = inject_ints.length; --i >= 0; ) {
const Q = inject_ints [i];
ss.push ('{ call: ' + Q.call.name + ', params: ' + JSON.stringify (Q.params || []) + '},');
}
ss.push ('];');
ss.push (InjectInterval.toString ());
ss.push ('setInterval (InjectInterval, 1000);');
ss.push ('console.log ("Fixes injected");');
ss.push ('}) ();');
ss = ss.join ('\n');
let sse = document.createElement ('script');
sse.setAttribute ('id', 'ytfixscript');
sse.appendChild (document.createTextNode (ss));
(document.body || document.head || document.documentElement).appendChild (sse);
console.log ('Fixes loaded');
}) ();
/////////////////////////////////////////////////////
//prima di continuare su youtube
document.cookie = "CONSENT=YES+cb.20210328-17-p0.it+FX+274; domain=.youtube.com;max-age=315360000";
if (document.URL == "https://consent.youtube.com/m?continue=https%3A%2F%2Fwww.youtube.com%2F%3Fhl%3Dit%26gl%3DIT&gl=IT&m=0&pc=yt&uxe=23983172&hl=it&src=1") window.location.href = "https://www.youtube.com/";
//browser edge
if (document.URL == "https://consent.youtube.com/ml?continue=https://www.youtube.com/?hl%3Dit%26gl%3DIT&gl=IT&hl=it&pc=yt&uxe=23983172&src=1") window.location.href = "https://www.youtube.com/";
/////////////////////////////
//f5=20000 autoplay on f5=30000 autoplay off
//document.cookie = "PREF=f1=50000000&f5=30000&f6=400; domain=.youtube.com;max-age=315360000";
document.cookie = "PREF=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; }`);
//popup non hai eseguito laccesso
GM_addStyle(`yt-tooltip-renderer{ 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; width:19px!important;",
"}",
"::-webkit-scrollbar-thumb {background-color: #272727!important;border-radius: 16px!important; box-shadow: inset 0 0 0 2px green!important;}",
///////////////////pulsanti sotto freccine su e giu
"::-webkit-scrollbar-button { background-color: red; }",
///////////////////////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);
}
}
})();
//////////////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;}');
/* progress bar barra avanzamento video */
GM_addStyle('.html5-play-progress, .ytp-play-progress { background: green!important; }');