Youtube Dark figuccio

youtube dark mode stop riproduzione autom

目前为 2021-02-28 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Youtube Dark figuccio
  3. // @namespace https://greasyfork.org/users/237458
  4. // @version 2.6
  5. // @description youtube dark mode stop riproduzione autom
  6. // @author figuccio
  7. // @match https://*.youtube.com/*
  8. // @run-at document-start
  9. // @grant GM_addStyle
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // @noframes
  13. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
  14. // ==/UserScript==
  15. //f5=20000 autoplay on f5=30000 autoplay off
  16. document.cookie = "PREF=f1=50000000&f5=30000&f6=400; domain=.youtube.com;max-age=315360000";
  17. //Rimuovi Youtube Commenti
  18. GM_addStyle('ytd-comments.style-scope{ display:none !important; }');
  19. //adblock grosso banner youtube premium
  20. GM_addStyle(`#masthead-ad { display: none !important; }`);
  21.  
  22. //promemoria privacy
  23. document.cookie = "HideTicker=true;domain=.youtube.com;max-age=315360000";
  24. //annotazioni video
  25. GM_addStyle(`.html5-video-player .ytp-cards-button{ display: none !important; }`);
  26. //////////////////// hide "guide" menu
  27. $(document).ready(function() {
  28. (function() {
  29. var guide_button=document.getElementById('guide-button');
  30. if(guide_button){
  31. var tmp=guide_button.getElementsByTagName('button');
  32. if(tmp.length) {
  33. tmp=tmp[0].attributes;
  34. if(tmp&&tmp['aria-pressed'].value=='true')
  35. guide_button.click();
  36. }
  37. }
  38. })();
  39.  
  40. });
  41.  
  42. //youtube stai zitto
  43. (function(){
  44. "use strict";
  45. function consent() {
  46. var e=document.querySelector('#introAgreeButton');
  47. e && e.click();
  48. }
  49. if (location.href.startsWith('https://consent.youtube.com/')) {
  50. if (document.readyState != 'loading') consent();
  51. else document.addEventListener('DOMContentLoaded', consent);
  52. return;
  53. }
  54.  
  55. function cookies() {
  56. var r={}, a=document.cookie;
  57. a.split(';').forEach(function(e){
  58. var p=e.split('=');
  59. if (p[0]) r[p.shift().trim()]=p.join('=');
  60. });
  61. return r;
  62. }
  63.  
  64. var ck=cookies();
  65. if (ck['APISID']) return;
  66.  
  67. function SImutF(mutL){
  68. for (let mut of mutL) {
  69. var t=mut.target;
  70. if ( (t.id=='dismiss-button') || (t.parentNode && (t.parentNode.id=='dismiss-button')) ) {
  71. if (t.classList.contains('yt-upsell-dialog-renderer') || t.classList.contains('ytd-mealbar-promo-renderer')) ;
  72. else if (t.classList.contains('yt-tooltip-renderer')) {
  73. t=t.querySelector('yt-button-renderer');
  74. if (!t) continue;
  75. }
  76. else continue;
  77. setTimeout(function(){t.click()}, 300);
  78. subObs.observe(t,{attributes: true, subtree: true});
  79. return;
  80. }
  81. }
  82. }
  83. var obs=new MutationObserver(SImutF);
  84. var subObs=new MutationObserver(SImutF);
  85. var obs2=new MutationObserver(function(mutL){
  86. for (let mut of mutL) {
  87. for (let n of mut.addedNodes) {
  88. if (n.nodeName == 'YTD-POPUP-CONTAINER') {
  89. this.disconnect();
  90. setObs();
  91. return;
  92. }
  93. }
  94. }
  95. });
  96. var obs3=new MutationObserver(function(mutL){
  97. for (let mut of mutL) {
  98. for (let n of mut.addedNodes) {
  99. if (n.nodeName == 'YTD-CONSENT-BUMP-LIGHTBOX') {
  100. this.disconnect();
  101. setTimeout(function(){
  102. let ck=cookies();
  103. if (ck['CONSENT'] && !ck['CONSENT'].startsWith('YES')) document.cookie='CONSENT=YES+;path=/;secure;domain=youtube.com;expires='+(new Date(Date.now()+567648000000)).toUTCString()+';';
  104. }, 5000);
  105. return;
  106. }
  107. }
  108. }
  109. });
  110.  
  111. function init() {
  112. var t;
  113. if (document.querySelector('ytm-app')) {
  114. new MutationObserver(function(mutL){
  115. for (let mut of mutL) {
  116. for (let n of mut.addedNodes) {
  117. if (n.classList.contains('upsell-dialog-lightbox') || n.classList.contains('consent-bump-lightbox') ) {
  118. if (t=document.querySelector('.upsell-dialog-dismiss-button button, .consent-bump-button-wrapper button')) {
  119. t.click();
  120. }
  121. }
  122. }
  123. }
  124. }).observe(document.body, {childList: true, subtree: false});
  125. }
  126.  
  127. setObs();
  128. if (ck['CONSENT'] && !ck['CONSENT'].startsWith('YES')) {
  129. obs3.observe(document.body, {childList:true});
  130. setTimeout(function(){obs3.disconnect();},30000);
  131. }
  132. }
  133.  
  134. var c=1;
  135. function setObs(){
  136. var r=document.querySelector('ytd-app ytd-popup-container');
  137. if (!r) {
  138. if (c--) obs2.observe(document.querySelector('ytd-app'), {childList:true});
  139. return;
  140. }
  141. obs.observe(r, {childList: true, subtree: true});
  142. }
  143. if (document.readyState != 'loading') init();
  144. else document.addEventListener('DOMContentLoaded', init);
  145.  
  146. var s=document.createElement('style');
  147. (document.head || document.documentElement).appendChild(s);
  148. 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;}";
  149.  
  150. s=document.createElement('script');
  151. s.textContent= `(function(){var c=80, pl, plR, oldp={};
  152. function f(){
  153. plR=document.querySelector('ytd-player#ytd-player');
  154. if (plR) pl=plR.getPlayer();
  155. if (!pl) {
  156. if (--c) setTimeout(f,200);
  157. else if (plR) {
  158. var obs=new MutationObserver(function(mutL){
  159. for (let mut of mutL) {
  160. for (let n of mut.addedNodes) {
  161. if (n.id == 'movie_player') {
  162. this.disconnect();
  163. pl=plR.getPlayer();
  164. init();
  165. return;
  166. }
  167. }
  168. }
  169. }).observe(document.querySelector('ytd-app'), {childList: true, subtree: true});
  170. }
  171. return;
  172. }
  173. else init();
  174. }
  175. if (document.readyState != 'loading') f();
  176. else document.addEventListener('DOMContentLoaded', f);
  177.  
  178. function init() {
  179. for (let i in pl) if (typeof pl[i] == 'function') {
  180. if ( !['cancelPlayback', 'pauseVideo', 'stopVideo', 'playVideo'].includes(i) ) continue;
  181. oldp[i]=pl[i];
  182. pl[i]=function() {
  183. let st=(new Error()).stack;
  184. if ( (st.search(/(\\.onFulfilled|scheduler\\.js:|handlePopupClose_)/)>0) && (st.search(/onYtStopOldPlayer_/) ==-1) ) return;
  185. oldp[i].apply(this,arguments);
  186. }
  187. }
  188. }
  189. })();`;
  190.  
  191. (document.head || document.documentElement).appendChild(s);
  192. if (s.parentNode) s.parentNode.removeChild(s);
  193. })();
  194.  
  195. ///////////////////////////////////////////////////////////////////////////
  196. GM_addStyle('#country-code::after{content: " yuotube Dark figuccio" }');
  197. GM_addStyle('#country-code.ytd-topbar-logo-renderer {color:red!important; }');
  198. ///////////////////////////////////////////////////////////////////////////clock
  199. $(document).ready(function() {
  200. (function() {
  201. 'use strict';
  202. GM_addStyle('.ytp-time-display {color:!important;}');
  203. let bar = document.getElementsByClassName("ytp-right-controls")[0];
  204. let clock = document.createElement("span");
  205. clock.classList.add("ytp-time-display");
  206. clock.innerText = "Toto";
  207. function clockTime() {
  208. var today = new Date();
  209. var h = today.getHours();
  210. var m = today.getMinutes();
  211. var s = today.getSeconds();
  212. var milli = today.getMilliseconds()
  213. if (h < 10) h = "0" + h;
  214. if (m < 10) m = "0" + m;
  215. if (s < 10) s = "0" + s;
  216. clock.innerText = h + ":" + m + ":" + s+ ":" +milli;
  217. setTimeout(clockTime, 70);
  218. }
  219. clockTime();
  220. bar.insertBefore(clock, bar.childNodes[0]);
  221. })();
  222. });
  223. ////////////////////////////////ricarica da solo youtube cosi lorologio si vede sempre
  224. function redirect_yt() {
  225. if (!window.location.hash) {
  226. if (document.location.toString().indexOf("watch?v=") != -1) {
  227. window.location.replace(window.location.href+"#fix");
  228. }
  229. }
  230. }
  231.  
  232. var url = document.location.toString();
  233. document.querySelector('html').addEventListener('DOMNodeInserted', function(ev){
  234. var new_url = document.location.toString();
  235. if (url == new_url) return; //già controllato o elaborato
  236. url = new_url;
  237.  
  238. redirect_yt() // eseguito quando l'URL cambia
  239. });
  240.  
  241. setTimeout(() => { redirect_yt(); }, 1000);
  242.  
  243. //rimuove publicita video
  244. const host_url = location.host;
  245.  
  246. if (host_url === "www.youtube.com") {
  247. setInterval(
  248. function () {
  249. try {
  250. const elem1 = document.getElementsByClassName("ytp-ad-overlay-close-container");
  251. elem1[0].click();
  252. } catch (e) {
  253. ;
  254. }
  255. try {
  256. const elem2 = document.getElementsByClassName("ytp-ad-skip-button-container");
  257. elem2[0].click();
  258. } catch (e) {
  259. ;
  260. }
  261. }, 1000
  262. )
  263. }
  264.  
  265. ///////////rimuove scritta consigliati allinterno video
  266. GM_addStyle('.ytp-cards-teaser-label{ display:none !important; }');
  267. ///////////traduci//////////////
  268. (() => {
  269. const translate = () => {
  270. const onLoadStart = () => {
  271. const clickActive = (clickBtn, role = "menuitemradio") => {
  272. const theNode = $(`[role=${role}]:contains(${clickBtn})`)
  273. theNode.length ? theNode.click() : ''
  274. }
  275. const ccBtnT = $('.ytp-subtitles-button[aria-pressed="true"][style=""]')
  276. const ccBtnF = $('.ytp-subtitles-button[aria-pressed="false"][style=""]')
  277. if (!(ccBtnT.length + ccBtnF.length)) return
  278. ccBtnF.click()
  279. $('.ytp-settings-button').click()
  280. clickActive("字幕", "menuitem")
  281. clickActive("中文(简体)")
  282. clickActive("中文(中国)")
  283. clickActive("自动翻译")
  284. clickActive("中文(简体)")
  285. //chiude impostazioni
  286. $('.ytp-settings-button').click()
  287. }
  288. $('video').on('loadstart', onLoadStart).trigger('loadstart')
  289. }
  290. translate()
  291. const intervalNum = setInterval(()=>{
  292. const videoNode = document.querySelector('video')
  293. if (videoNode) {
  294. videoNode.addEventListener('resize', () => { console.log('resize');translate() },{once:true})
  295. clearInterval(intervalNum)
  296. }
  297. },500)
  298. })()
  299.  
  300. ///////////icome home ecc e titoli home tendenze ecc
  301. GM_addStyle('.title,.pieSegment,svg { color: #5f84f1 !important;}');
  302. //scrittura verde
  303. 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;}');
  304. //scrollbar nera
  305. (function() {var css = "";
  306. css += [
  307. "/*####----BROWSER SCROLL BAR----####*/",
  308. "::-webkit-scrollbar {",
  309. "background: -webkit-linear-gradient(40deg , #040404 , #0C0C0C , #040404 100%)!important;",
  310. "border-left: 1px solid #1A1A1A !important;",
  311. "}",
  312. "::-webkit-scrollbar-thumb {background-color: #272727!important;border-radius: 16px!important;}",
  313. ].join("\n");
  314.  
  315. if (typeof GM_addStyle != "undefined") {
  316. GM_addStyle(css);
  317. } else if (typeof PRO_addStyle != "undefined") {
  318. PRO_addStyle(css);
  319. } else if (typeof addStyle != "undefined") {
  320. addStyle(css);
  321. } else {
  322. var node = document.createElement("style");
  323. node.type = "text/css";
  324. node.appendChild(document.createTextNode(css));
  325. var heads = document.getElementsByTagName("head");
  326. if (heads.length > 0) {
  327. heads[0].appendChild(node);
  328. } else {
  329. // no head yet, stick it whereever
  330. document.documentElement.appendChild(node);
  331. }
  332. }
  333. })();
  334.