YouTube - Shrink watched YouTube videos

Youtube videos will be shrinked so you can easily/visuallyClearly skip them.

当前为 2020-01-30 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name       YouTube - Shrink watched YouTube videos
// @version    1.05 beta
// @description Youtube videos will be shrinked so you can easily/visuallyClearly skip them.
// @description Based in the work of Aviem Zur "YouTube - Hide watched YouTube videos" (http://userscripts-mirror.org/scripts/review/149842). Forum: https://greasyfork.org/en/forum/discussion/comment/21182.
// @description I understand it will work best with "Better YouTube Watch History" (https://chrome.google.com/webstore/detail/better-youtube-watch-hist/lleajdkalfbohpinoaekajagdefaeckd?hl=en)
// @match      http://www.youtube.com/*
// @match      http://youtube.com/*
// @match      https://www.youtube.com/*
// @match      https://youtube.com/*
// @license    GPLv3 - http://www.gnu.org/licenses/gpl-3.0.en.html
// @copyright  teken
// @namespace https://greasyfork.org/users/17433
// ==/UserScript==

var hide = function() {
    var aElementList = [];
    var watchedList;
/*
    watchedList = document.evaluate("//div[contains(text(),'WATCHED')]/../../../..",document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
    for (var i = 0; i < watchedList.snapshotLength; i++) {var w = watchedList.snapshotItem(i);aElementList.push(w);}
    
    watchedList = document.evaluate("//span[contains(text(),'WATCHED')]/../../../..",document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
    for (var i = 0; i < watchedList.snapshotLength; i++) {var w = watchedList.snapshotItem(i);aElementList.push(w);}
    
    watchedList = document.evaluate("//span[@class='resume-playback-background']/../../..",document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
    for (var i = 0; i < watchedList.snapshotLength; i++) {var w = watchedList.snapshotItem(i);aElementList.push(w);}

    watchedList = document.evaluate("//span[@class='resume-playback-progress-bar']/../../..",document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
    for (var i = 0; i < watchedList.snapshotLength; i++) {var w = watchedList.snapshotItem(i);aElementList.push(w);}
*/
    watchedList = document.evaluate("//div[@id='progress']/../../..",document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
    for (var i = 0; i < watchedList.snapshotLength; i++) {var w = watchedList.snapshotItem(i);aElementList.push(w);}

    for (var i = 0; i < aElementList.length; i++) {
        var w = aElementList[i];
        var pic = null;
        var bRows=false;
/*
        if(!pic){
            bRows=true;
            pic = w.getElementsByClassName("yt-thumb-default")[0]; //tiled list of videos is this one
        }
        if(!pic){
            bRows=true;
            pic = w.getElementsByClassName("yt-thumb video-thumb")[0]; // one video per row is this one
        }
        if(!pic){
            bRows=true;
            pic = w.getElementsByClassName("thumb-link spf-link yt-uix-sessionlink")[0]; // one video per row is this one
        }
*/
        if(!pic){
            bRows=true;
            pic = w.getElementsByClassName("style-scope yt-img-shadow")[0]; // one video per row is this one
        }
        pic.style.display = 'none';
        
        if(bRows){
            w.style.height = '10px';w.style.overflow = 'hidden';
        }
        w.style.backgroundColor = "#401030";
    }
};

document.addEventListener("DOMSubtreeModified", function() { hide(); } , false);