Youtube Gray-Out

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

当前为 2016-09-20 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Youtube Gray-Out
  3. // @namespace http://do20c2oidj11xsy0ujgb2.com
  4. // @version 1.0
  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.justifyContent = 'center';
  29. E.style.color = '#ff9bf1';
  30. function check(){
  31.  
  32. A = GM_getValue('YoutubeSeenVideos', {});
  33.  
  34. window.location.href==X || evaluate();
  35. if(!is_video_page()) fix_thumbnails(); //setTimeout(fix_thumbnails,3000);
  36. }
  37.  
  38. function fix_thumbnails(){
  39. D = Object.getOwnPropertyNames(A);
  40.  
  41. C = document.getElementsByTagName('img');
  42.  
  43. for(var x=0; x<C.length; x++){
  44. if(is_fixed(C[x])) continue;
  45. for(var y=0; y<D.length; y++) if(C[x].src.indexOf(D[y])!=-1){
  46. F = C[x].parentNode.appendChild(E.cloneNode());
  47. F.innerHTML = A[D[y]]; break;
  48. };
  49. C[x].setAttribute('grayout-status', true);
  50. }
  51. }
  52.  
  53. function is_fixed(e,s){
  54. if((s=e.getAttribute('grayout-status'))==undefined) return false;
  55. return true;
  56. }
  57.  
  58. function is_video_page(){
  59. return window.location.href.indexOf('watch') != -1;
  60. }
  61.  
  62. function update_video_list(){
  63. B=/v=([a-zA-Z0-9-_]+)/g.exec(window.location.href)[1];
  64. A[B]===undefined && (A[B]=0); A[B]++;
  65. }
  66.  
  67. function evaluate() {
  68.  
  69. X = window.location.href;
  70.  
  71. is_video_page() && update_video_list();
  72. GM_setValue('YoutubeSeenVideos', A);
  73. }
  74.  
  75. T = window.setInterval(check,1200);
  76. })();