您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
YouTubeでおすすめに表示される再生回数の少ない動画を非表示にします。コードから再生回数のしきい値を変更できます。デフォルトでは1000再生数以下の動画を非表示に設定しています。登録チャンネル内の動画は無視するオプションを追加しました。
当前为
// ==UserScript== // @name YouTube用低視聴回数動画の非表示 // @namespace http://tampermonkey.net/ // @description YouTubeでおすすめに表示される再生回数の少ない動画を非表示にします。コードから再生回数のしきい値を変更できます。デフォルトでは1000再生数以下の動画を非表示に設定しています。登録チャンネル内の動画は無視するオプションを追加しました。 // @author sun // @match *://*.youtube.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com // @grant GM_registerMenuCommand // @version 1.31 // ==/UserScript== const VIEW_THRESHOLD = 1000; const DISABLE_ON_SUBSCRIPTIONS = true; const OPTION_STORAGE_KEY = 'YT_LowViewFilter_Settings'; const VIDEO_SELECTORS = "ytd-rich-item-renderer, ytd-compact-video-renderer"; const VIEW_COUNT_SELECTOR = ".inline-metadata-item.style-scope.ytd-video-meta-block"; let menuRegistered = false; function parseViewCount(text) { if (!text) return 0; const multipliers = { "K": 1e3, "M": 1e6, "万": 1e4, "億": 1e8 }; let numText = text.replace(/[^0-9\.KM万億]/g, ""); let unit = Object.keys(multipliers).find(u => numText.includes(u)) || ""; numText = numText.replace(unit, ""); return numText ? parseFloat(numText) * (multipliers[unit] || 1) : 0; } function isBadVideo(videoViews) { if (!videoViews) return false; const viewCount = parseViewCount(videoViews.innerText); return viewCount > 0 && viewCount < VIEW_THRESHOLD; } function isSubscriptionsPage() { return location.pathname.includes('/@') && location.pathname.includes('/videos'); } function isLivePage() { return location.pathname.includes('/streams'); } function getSettings() { return JSON.parse(localStorage.getItem(OPTION_STORAGE_KEY)) || { disableOnSubs: DISABLE_ON_SUBSCRIPTIONS }; } function hideBadVideo(videoElement) { if (!videoElement || isLivePage()) return; const { disableOnSubs } = getSettings(); if (disableOnSubs && isSubscriptionsPage()) return; const videoViews = videoElement.querySelector(VIEW_COUNT_SELECTOR); if (isBadVideo(videoViews)) videoElement.style.display = "none"; } const observer = new IntersectionObserver(entries => { entries.forEach(entry => { if (entry.isIntersecting) { hideBadVideo(entry.target); observer.unobserve(entry.target); } }); }, { rootMargin: "300px" }); function update() { if (isLivePage()) return; document.querySelectorAll(VIDEO_SELECTORS).forEach(video => { hideBadVideo(video); observer.observe(video); }); } function initTampermonkeyMenu() { if (menuRegistered) return; menuRegistered = true; const { disableOnSubs } = getSettings(); GM_registerMenuCommand( `登録チャンネル内の動画は無視する: ${disableOnSubs ? "ON" : "OFF"}`, () => { localStorage.setItem(OPTION_STORAGE_KEY, JSON.stringify({ disableOnSubs: !disableOnSubs })); window.location.reload(); } ); } window.addEventListener("load", () => { initTampermonkeyMenu(); update(); const ytApp = document.querySelector("ytd-app"); if (ytApp) { ytApp.addEventListener("yt-navigate-finish", () => setTimeout(update, 500)); } const mutationObserver = new MutationObserver(mutations => { if (isLivePage()) return; mutations.forEach(mutation => { mutation.addedNodes.forEach(node => { if (node.nodeType !== 1) return; if (node.matches?.(VIDEO_SELECTORS)) { observer.observe(node); } else if (node.querySelectorAll) { node.querySelectorAll(VIDEO_SELECTORS).forEach(video => observer.observe(video)); } }); }); }); mutationObserver.observe(document.body, { childList: true, subtree: true }); });
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址