Youtube Gray-Out

Overlay thumbnails of already watched videos with white layer and view counter. Aims to counteract Youtube's clickbait design.

  1. // ==UserScript==
  2. // @name Youtube Gray-Out
  3. // @namespace http://do20c2oidj11xsy0ujgb2.com
  4. // @version 1.1
  5. // @description Overlay thumbnails of already watched videos with white layer and view counter. Aims to counteract Youtube's clickbait design.
  6. // @author BakaChan777
  7. // @run-at document-end
  8. // @match https://*.youtube.com/*
  9. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // @grant GM_log
  12. // ==/UserScript==
  13.  
  14. (function( A, B, C, D, E, F, X, T ){
  15. 'use strict';
  16.  
  17. E = document.createElement('div');
  18. E.style.width = '100%';
  19. E.style.height = '100%';
  20. E.style.position = 'absolute';
  21. E.style.backgroundColor = 'white';
  22. E.style.opacity = 0.8;
  23. E.style.top = '0px';
  24. E.style.lineHeight = '100%';
  25. E.style.fontSize = '50px';
  26. E.style.display = 'flex';
  27. E.style.alignItems = 'center';
  28. E.style.zIndex = '5000';
  29. E.style.justifyContent = 'center';
  30. E.style.color = '#ff9bf1';
  31.  
  32. function check(){
  33.  
  34. window.location.href==X || evaluate();
  35. fix_thumbnails();
  36. }
  37.  
  38. function fix_thumbnails(){
  39. C = document.querySelectorAll('[href^="/watch"] img[src]:not([grayout-status])');
  40. if(!C.length) return;
  41.  
  42. A = GM_getValue('YoutubeSeenVideos', {});
  43. D = Object.getOwnPropertyNames(A);
  44.  
  45. for(var x=0; x<C.length; x++){
  46. for(var y=0; y<D.length; y++) if(C[x].src.indexOf(D[y])!=-1){
  47. F = C[x].parentNode.insertBefore(E.cloneNode(),C[x]);
  48. F.innerHTML = A[D[y]]; break;
  49. };
  50. C[x].setAttribute('grayout-status', true);
  51. }
  52. }
  53.  
  54. function is_fixed(e,s){
  55. if((s=e.getAttribute('grayout-status'))==undefined) return false;
  56. return true;
  57. }
  58.  
  59. function is_video_page(){
  60. return window.location.href.indexOf('watch') != -1;
  61. }
  62.  
  63. function update_video_list(){
  64. B=/v=([a-zA-Z0-9-_]+)/g.exec(window.location.href)[1];
  65. A[B]===undefined && (A[B]=0); A[B]++;
  66.  
  67. //update or generate thumbnail of current video
  68.  
  69. for(var x = 0, y = document.querySelectorAll('img[src*="'+B+'"]'); x<y.length; x++){
  70. if(y[x].parentNode.firstChild == y[x])
  71. F = y[x].parentNode.insertBefore(E.cloneNode(),y[x]);
  72. else
  73. F = y[x].parentNode.firstChild;
  74. F.innerHTML = A[B];
  75. }
  76. }
  77.  
  78. function evaluate() {
  79. A = GM_getValue('YoutubeSeenVideos', {});
  80. X = window.location.href;
  81.  
  82. is_video_page() && update_video_list();
  83. GM_setValue('YoutubeSeenVideos', A);
  84. }
  85.  
  86. window.addEventListener('yt-visibility-refresh', check);
  87. check();
  88.  
  89. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址