您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Removes branding images (elements with class 'branding-img') from YouTube pages to provide a cleaner interface.
- // ==UserScript==
- // @name YouTube Branding Image Remover
- // @namespace http://tampermonkey.net/
- // @version 0.3
- // @description Removes branding images (elements with class 'branding-img') from YouTube pages to provide a cleaner interface.
- // @author Your Name/AI
- // @match *://*.youtube.com/*
- // @grant none
- // @run-at document-end
- // ==/UserScript==
- (function() {
- 'use strict';
- function removeBrandingImages() {
- const images = document.querySelectorAll('img.branding-img');
- let imagesRemovedThisRun = 0;
- images.forEach(img => {
- if (document.body.contains(img)) {
- img.remove();
- imagesRemovedThisRun++;
- }
- });
- if (imagesRemovedThisRun > 0) {
- // console.log(`[YouTube Branding Image Remover] Removed ${imagesRemovedThisRun} branding image(s).`);
- }
- }
- // Initial run
- removeBrandingImages();
- // Observe DOM changes for dynamically loaded content
- const observer = new MutationObserver(function(mutationsList, observerInstance) {
- let potentiallyNewBrandingImages = false;
- for(const mutation of mutationsList) {
- if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
- for (const node of mutation.addedNodes) {
- if (node.nodeType === 1) {
- if (node.matches && node.matches('img.branding-img')) {
- potentiallyNewBrandingImages = true;
- break;
- }
- if (node.querySelector && node.querySelector('img.branding-img')) {
- potentiallyNewBrandingImages = true;
- break;
- }
- }
- }
- }
- if (potentiallyNewBrandingImages) break;
- }
- if (potentiallyNewBrandingImages) {
- removeBrandingImages();
- }
- });
- function startObserver() {
- if (document.body) {
- observer.observe(document.body, { childList: true, subtree: true });
- } else {
- document.addEventListener('DOMContentLoaded', function() {
- observer.observe(document.body, { childList: true, subtree: true });
- });
- }
- }
- startObserver();
- })();