脚本猫专用网站脚本(B站+抖音+知乎+百度网盘) // ==UserScript== // @name 脚本猫专用网站脚本(B站+抖音+知乎+百度网盘) // @namespace https://scriptcat.org/ // @version 1.0.1 // @description 适配B站、抖音、知乎、百度网盘,自带实用功能 // @author 脚本猫用户 // @match *://*.bilibili.com/* // B站专用匹配 // @match *://*.douyin.com/* // 抖音专用匹配 // @match *://*.zhihu.com/* // 知乎专用匹配 // @match *://pan.baidu.com/* // 百度网盘专用匹配 // @grant none // @run-at document-end // @license MIT // ==/UserScript== (function() { 'use strict'; // ============================================== // 1. B站专用功能(可单独关闭,注释即可) // ============================================== function bilibiliFunction() { // 适配B站域名判断,避免影响其他网站 if (window.location.host.includes("bilibili.com")) { console.log("✅ B站专用脚本已加载"); // 功能1:自动关闭B站首页弹窗(登录、广告弹窗) const closePopup = () => { const popups = document.querySelectorAll(".bilibili-player-video-mask, .popup-close, .modal-close"); popups.forEach(popup => popup.click()); }; // 功能2:移除B站视频页广告(弹幕广告、侧边广告) const removeBilibiliAds = () => { const adSelectors = [ ".ad-floor", ".ad-sidebar", ".bpx-player-ad", ".video-page-special-ad", "[class*='ad-']", "[id*='ad-']" ]; adSelectors.forEach(selector => { document.querySelectorAll(selector).forEach(el => el.remove()); }); }; // 功能3:自动展开B站评论区(无需点击“展开”) const expandComments = () => { const expandBtns = document.querySelectorAll(".comment-expand-btn"); expandBtns.forEach(btn => btn.click()); }; // 页面加载+定时执行(应对动态加载的广告/弹窗) window.addEventListener('load', () => { closePopup(); removeBilibiliAds(); expandComments(); // 定时检查,防止动态加载的广告 setInterval(() => { closePopup(); removeBilibiliAds(); }, 3000); }); } } // ============================================== // 2. 抖音专用功能(可单独关闭,注释即可) // ============================================== function douyinFunction() { if (window.location.host.includes("douyin.com")) { console.log("✅ 抖音专用脚本已加载"); // 功能1:移除抖音视频页广告(信息流广告、底部广告) const removeDouyinAds = () => { const adSelectors = [ ".ad-container", ".feed-card-ad", ".ad-tag", ".promotion-content", "[data-type='ad']" ]; adSelectors.forEach(selector => { document.querySelectorAll(selector).forEach(el => el.remove()); }); }; // 功能2:自动关闭抖音弹窗(登录提示、活动弹窗) const closeDouyinPopup = () => { const closeBtns = document.querySelectorAll(".close-btn, .popup-close, .dy-modal-close"); closeBtns.forEach(btn => btn.click()); }; // 功能3:关闭抖音自动播放下一个视频(按需开启,注释即关闭) // const stopAutoPlay = () => { // const video = document.querySelector("video"); // if (video) { // video.addEventListener("ended", (e) => { // e.preventDefault(); // video.pause(); // }); // } // }; window.addEventListener('load', () => { closeDouyinPopup(); removeDouyinAds(); // stopAutoPlay(); // 按需开启,取消注释即可 setInterval(() => { closeDouyinPopup(); removeDouyinAds(); }, 2000); }); } } // ============================================== // 3. 知乎专用功能(可单独关闭,注释即可) // ============================================== function zhihuFunction() { if (window.location.host.includes("zhihu.com")) { console.log("✅ 知乎专用脚本已加载"); // 功能1:移除知乎广告(信息流广告、侧边广告) const removeZhihuAds = () => { const adSelectors = [ ".Topstory-ad", ".AdaptiveAD", ".ad-item", ".commercial-unit", "[class*='ad-']" ]; adSelectors.forEach(selector => { document.querySelectorAll(selector).forEach(el => el.remove()); }); }; // 功能2:自动关闭知乎弹窗(登录、会员提示) const closeZhihuPopup = () => { const closeBtns = document.querySelectorAll(".Modal-close, .close, .Popover-close"); closeBtns.forEach(btn => btn.click()); // 移除登录遮罩 const mask = document.querySelector(".Modal-backdrop"); if (mask) mask.remove(); }; // 功能3:展开知乎全部回答(无需点击“查看更多”) const expandAnswers = () => { const moreBtns = document.querySelectorAll(".Button--more"); moreBtns.forEach(btn => { if (btn.textContent.includes("查看更多")) btn.click(); }); }; window.addEventListener('load', () => { closeZhihuPopup(); removeZhihuAds(); expandAnswers(); setInterval(() => { closeZhihuPopup(); removeZhihuAds(); }, 2500); }); } } // ============================================== // 4. 百度网盘专用功能(可单独关闭,注释即可) // ============================================== function baiduPanFunction() { if (window.location.host.includes("pan.baidu.com")) { console.log("✅ 百度网盘专用脚本已加载"); // 功能1:移除百度网盘广告(顶部广告、侧边广告) const removePanAds = () => { const adSelectors = [ ".ad-banner", ".ad-sidebar", ".promo-ad", ".ad-container", "[id*='ad']" ]; adSelectors.forEach(selector => { document.querySelectorAll(selector).forEach(el => el.remove()); }); }; // 功能2:自动关闭网盘弹窗(会员提示、活动弹窗) const closePanPopup = () => { const closeBtns = document.querySelectorAll(".close-btn, .dialog-close, .popup-close"); closeBtns.forEach(btn => btn.click()); }; // 功能3:默认显示全部文件(取消“仅显示图片/视频”筛选) const showAllFiles = () => { const allBtn = document.querySelector(".file-type-tab[data-type='all']"); if (allBtn && !allBtn.classList.contains("active")) { allBtn.click(); } }; window.addEventListener('load', () => { closePanPopup(); removePanAds(); showAllFiles(); setInterval(() => { closePanPopup(); removePanAds(); }, 3000); }); } } // ============================================== // 执行所有网站功能(可注释单个函数,关闭对应网站功能) // ============================================== bilibiliFunction(); douyinFunction(); zhihuFunction(); baiduPanFunction(); })();