YT Channel Query Fix

Remove external (channel) videos in queries.

ของเมื่อวันที่ 26-08-2019 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         YT Channel Query Fix
// @namespace    youtube.scripts
// @version      1.3
// @description  Remove external (channel) videos in queries.
// @include      *.youtube.com/*search*
// ==/UserScript==

(function() {
    'use strict';

    const INTERVAL = 500;
    const MAX_HITS = 5;

    const this_channel = location.href.match(/(.*)\//)[1];
    var hits = 0;
    var id = setInterval(() => {
        let ns = document.querySelectorAll("ytd-item-section-renderer");
        for(let e of ns) {
            let a = e.querySelector("#metadata a");
            if(!e.hidden && a.href != this_channel) {
                e.hidden = true;
                hits = hits + 1;
                if(hits >= MAX_HITS) {
                    clearInterval(id);
                    break;
                }
            }
        }
    }, INTERVAL);
})();