YouTube - Shrink watched YouTube videos

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

目前為 2020-01-30 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name       YouTube - Shrink watched YouTube videos
// @version    1.04 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 = w.getElementsByClassName("yt-thumb-default")[0]; //tiled list of videos is this one
        var bRows=false;
        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);