您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
to remove ads slots in YouTube main page
当前为
- // ==UserScript==
- // @name Remove Ads Slots in YouTube Main Page
- // @namespace http://tampermonkey.net/
- // @version 0.1.5
- // @license MIT
- // @author CY Fung
- // @match https://www.youtube.com/*
- // @exclude /^https?://\S+\.(txt|png|jpg|jpeg|gif|xml|svg|manifest|log|ini)[^\/]*$/
- // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
- // @grant none
- // @run-at document-start
- // @require https://update.greasyfork.org/scripts/465819/1304833/API%20for%20CustomElements%20in%20YouTube.js
- // @description to remove ads slots in YouTube main page
- // ==/UserScript==
- (function () {
- 'use strict';
- const wm = new WeakSet();
- const removeAdsSlot = async (grid) => {
- const td = grid.data;
- if (td && !wm.has(td)) {
- const md = Object.assign({}, td);
- md.contents = md.contents.filter(content => {
- let isadSlotRenderer = ((((content || 0).richItemRenderer || 0).content || 0).adSlotRenderer || null) !== null;
- return isadSlotRenderer ? false : true;
- });
- wm.add(md);
- grid.data = md;
- }
- }
- customYtElements.whenRegistered('ytd-rich-grid-renderer', (proto) => {
- proto.dataChanged = ((dataChanged) => {
- return function () {
- removeAdsSlot(this);
- return dataChanged.apply(this, arguments);
- }
- })(proto.dataChanged)
- });
- })();