// ==UserScript== // @name 隐藏b站视频详情页右侧的推广 // @name:en Hide the promotional activities on the right side of Bilibili's video details page // @namespace http://tampermonkey.net/ // @version 0.1 // @description Hide specified Bilibili elements using MutationObserver // @description:en Hide specified Bilibili elements using MutationObserver // @author aspen138 // @match *://www.bilibili.com/video/* // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Function to hide the specified elements function hideElements() { var adBanner = document.getElementById('right-bottom-banner'); var liveCard = document.querySelector('.pop-live-small-mode.part-undefined'); if (adBanner) { adBanner.style.display = 'none'; } if (liveCard) { liveCard.style.display = 'none'; } } // Create a MutationObserver to watch for changes in the DOM var observer = new MutationObserver(function(mutationsList) { // Check each mutation for added nodes for (var mutation of mutationsList) { if (mutation.type === 'childList') { // If added nodes are detected, hide the elements hideElements(); } } }); // Start observing changes in the body and its subtree observer.observe(document.body, { childList: true, subtree: true }); // Initial hiding of elements when the script is executed hideElements(); })();