您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Skrývá videa na YouTube pod určitý čas videa (minuty) ⛔
=====================================
POPIS SKRIPTU – ČESKY
=====================================
Název: Skript pro skrytí videí na YouTube podle délky
Autor: Projekt Darkside - DevIT Brno - EU
Popis:
Tento userscript je určen pro Tampermonkey a funguje na webu YouTube. Jeho úkolem je automaticky skryt všechna videa, která jsou kratší než uživatelem nastavená minimální délka (v minutách). Skript prochází všechny bloky videí na stránce, zjišťuje délku každého videa (zobrazenou na miniatuře) a porovnává ji s nastavenou hodnotou. Pokud je video kratší než požadovaný čas, skript ho skryje (nastaví display:none).
Funkce skriptu:
1. Definuje proměnnou 'userMinVideoDurationMinutes', kde uživatel zadá minimální požadovanou délku videa v minutách.
2. Tato hodnota se automaticky přepočítá na sekundy a uloží do proměnné 'userMinVideoDuration'.
3. Skript běží každé 3 sekundy a prohledává stránku pomocí querySelectorAll pro následující selektory: 'ytd-video-renderer', 'ytd-grid-video-renderer', 'ytd-rich-item-renderer'.
4. V každém nalezeném bloku videa hledá element obsahující text s délkou videa (element s třídou 'badge-shape-wiz__text').
5. Text s časem (např. '2:15' nebo '1:02:03') rozdělí podle dvojteček a převede na sekundy:
- pokud jsou 2 části (MM:SS), vypočítá sekundy jako minuty*60 + sekundy
- pokud jsou 3 části (HH:MM:SS), vypočítá sekundy jako hodiny*3600 + minuty*60 + sekundy
- jinak vrátí 0
6. Pokud je délka videa v sekundách menší než nastavený limit, nastaví pro tento blok video.style.display = 'none', čímž video skryje ze stránky.
7. Skript počítá, kolik videí odstranil celkově a kolik jich odstranil v aktuálním cyklu.
8. Pokud je proměnná 'notificationsEnabled' nastavena na true, zobrazí v levém dolním rohu obrazovky oznámení o počtu odstraněných videí. Notifikace je vytvořena jako nový HTML element, má červené pozadí, bílý text, zaoblené rohy, ikonu zvonku a po 5 sekundách zmizí.
9. Skript se sám opakuje každé 3 sekundy pomocí setInterval, aby průběžně odstraňoval nově načtená videa při scrollování nebo automatickém načítání obsahu.
Další poznámky:
- Skript nemění původní obsah stránky, pouze skryje nežádoucí videa pomocí CSS display:none.
- Skript je pasivní – neblokuje síťová volání ani nezasahuje do API YouTube.
- Lze upravit proměnné přímo v kódu: minimální délku videa (userMinVideoDurationMinutes) a zapnutí notifikací (notificationsEnabled).
- Skript je určen pouze pro osobní použití a není oficiálně podporován YouTube.
=====================================
SCRIPT DESCRIPTION – ENGLISH
=====================================
Title: YouTube Video Hider by Duration Script
Author: Projekt Darkside - DevIT Brno - EU
Description:
This userscript is designed for Tampermonkey and works on YouTube. Its purpose is to automatically hide all videos shorter than a user-defined minimum length (in minutes). The script scans all video blocks on the page, reads the video duration displayed on thumbnails, and compares it with the configured threshold. If a video is shorter than the required time, the script hides it (by setting display:none).
Script functions:
1. Defines the variable 'userMinVideoDurationMinutes' where the user sets the minimum required video length in minutes.
2. This value is automatically converted into seconds and stored in the 'userMinVideoDuration' variable.
3. The script runs every 3 seconds and searches the page using querySelectorAll for the following selectors: 'ytd-video-renderer', 'ytd-grid-video-renderer', 'ytd-rich-item-renderer'.
4. In each found video block, it searches for an element containing the duration text (an element with the class 'badge-shape-wiz__text').
5. The time text (e.g. '2:15' or '1:02:03') is split by colons and converted into seconds:
- if there are 2 parts (MM:SS), calculates seconds as minutes*60 + seconds
- if there are 3 parts (HH:MM:SS), calculates seconds as hours*3600 + minutes*60 + seconds
- otherwise returns 0
6. If the video duration in seconds is less than the configured limit, it sets video.style.display = 'none' for that video block, hiding the video from the page.
7. The script keeps track of how many videos were removed in total and how many were removed in the current cycle.
8. If the 'notificationsEnabled' variable is set to true, it shows a notification in the lower-left corner of the screen with the number of removed videos. The notification is created as a new HTML element, with red background, white text, rounded corners, a bell icon, and fades out after 5 seconds.
9. The script repeats itself every 3 seconds using setInterval to continuously remove newly loaded videos during scrolling or automatic content loading.
Additional notes:
- The script does not modify the original page content; it only hides unwanted videos using CSS display:none.
- The script is passive – it does not block network requests or interfere with YouTube’s API.
- You can configure the variables directly in the code: minimum video length (userMinVideoDurationMinutes) and notification toggle (notificationsEnabled).
- This script is intended for personal use only and is not officially supported by YouTube.