关于屏蔽YouTube垂直格式视频(含#Shorts)的技术方案问询
关于屏蔽YouTube垂直格式视频(含#Shorts)的技术方案问询
兄弟我太懂你这种烦躁了——YouTube硬推Shorts把不少优质频道都带偏,那些竖屏短内容大多是凑数的,纯纯浪费时间!下面给你两种靠谱的解决方案,帮你自动过滤这类竖屏视频:
一、浏览器扩展/用户脚本方案(省心首选)
- 先装个Tampermonkey(油猴脚本管理器),这是浏览器里用来运行自定义脚本的工具,各大浏览器应用商店都能找到。
- 你可以自己写脚本(下面会给示例),或者直接在油猴的脚本社区搜关键词,比如「YouTube block vertical videos」「YouTube Shorts blocker」,很多现成的脚本直接就能用,核心逻辑都是检测视频宽高比,把竖屏内容藏起来。
二、自定义JavaScript代码(动手党专属)
如果想自己掌控逻辑,试试这个油猴脚本,它能自动扫描YouTube页面上的所有视频(包括首页、频道页、Shorts流和播放页),只要是高大于宽的竖屏内容,直接隐藏:
// ==UserScript== // @name YouTube竖屏视频屏蔽器 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 自动屏蔽YouTube上的竖屏视频(含Shorts) // @author 自定义 // @match *://*.youtube.com/* // @grant none // ==/UserScript== (function() { 'use strict'; // 核心检测屏蔽函数 function blockVerticalVideos() { // 处理常规视频卡片(首页/频道页) const regularCards = document.querySelectorAll('ytd-rich-item-renderer, ytd-video-renderer, ytd-grid-video-renderer'); regularCards.forEach(card => { const thumbnail = card.querySelector('img'); if (!thumbnail) return; const width = thumbnail.naturalWidth || thumbnail.width; const height = thumbnail.naturalHeight || thumbnail.height; // 宽高比小于1就是竖屏 if (height > width) { card.style.display = 'none'; } }); // 直接屏蔽所有Shorts卡片(本身就是竖屏) const shortCards = document.querySelectorAll('ytd-reel-item-renderer'); shortCards.forEach(card => { card.style.display = 'none'; }); // 处理播放页的竖屏视频 const player = document.querySelector('video'); if (player) { const width = player.videoWidth; const height = player.videoHeight; if (height > width) { player.style.display = 'none'; // 加个提示让你知道是被屏蔽了 const notice = document.createElement('div'); notice.textContent = '已自动屏蔽竖屏视频,省点时间干别的吧!'; notice.style.padding = '20px'; notice.style.fontSize = '18px'; notice.style.textAlign = 'center'; notice.style.background = '#f0f0f0'; player.parentElement.appendChild(notice); } } } // 页面加载完先跑一次 blockVerticalVideos(); // 监听页面动态加载(YouTube是无限滚动,新内容要实时检测) const observer = new MutationObserver(() => { blockVerticalVideos(); }); observer.observe(document.body, { childList: true, subtree: true }); })();
脚本说明:
- 会自动处理页面上所有动态加载的视频,包括滚动出来的新内容,不会漏网。
- 如果不想直接隐藏,也可以改成给卡片加个显眼的标记,比如把
card.style.display = 'none'改成card.style.border = '3px solid red',这样你能一眼分辨出来,手动选择是否跳过。
最后说两句
其实你不是唯一一个烦这个的人,很多YouTube老用户都在吐槽Shorts的低质量内容,这些方案亲测有效,能帮你把时间留给真正有价值的视频!
备注:内容来源于stack exchange,提问作者Ace Frahm
相关产品推荐
相关产品推荐

