您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
顶栏修改, 查看封面, 隐藏直播卡片遮罩, 隐藏底部弹幕, 隐藏聊天室 电竞直播间
// ==UserScript== // @name NYJX - bilibili // @namespace https://www.bilibili.com/ // @version 1.2.0 // @description 顶栏修改, 查看封面, 隐藏直播卡片遮罩, 隐藏底部弹幕, 隐藏聊天室 电竞直播间 // @author 能用就行 // @match *://*.bilibili.com/* // @exclude *://message.bilibili.com/* // @exclude *://www.bilibili.com/blackboard/* // @exclude *://live.bilibili.com/activity/live-activity-battle* // @exclude *://live.bilibili.com/live-room-play-game-together* // @exclude *://t.bilibili.com/share/card/index* // @icon https://www.bilibili.com/favicon.ico // @grant GM_setValue // @grant GM_getValue // @grant GM_addStyle // @license MIT // ==/UserScript== (function() { 'use strict'; GM_addStyle(` /* 聊天室直播卡片 */ #card[data-test="true_1"], /* 电竞派单直播卡片 */ .DJ, /* 底部弹幕 */ .bili-danmaku-x-center, /* 直播卡片遮罩 */ [class^="Item_player-mask_"], /* 直播logo */ .web-player-icon-roomStatus, /* 底部广告 */ .left-container .flip-view.p-relative.over-hidden, /* 动态页广告 */ .bili-dyn-ads, /* 顶栏 下载客户端 */ .download-entry.download-client-trigger, /* 广告屏蔽插件提示 */ .adblock-tips { display: none !important; } /* 直播马赛克 */ #web-player-module-area-mask-panel { opacity: 0; } /* 网页全屏 */ .player-full-win .cktp {display:none !important;} .cktp { display: flex; width: 38px; height: 38px; position: fixed; top: 25%; left: 5px; z-index: 9999; background-color: #eeeeeebb; border-radius: 50%; border: 1px solid #ddd; cursor: pointer; align-items: center; justify-content: center; } .cktpa { position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.3); display: none; align-items: center; z-index: 9998; justify-content: center; } .cktpa img {max-width: 90vw;max-height: 90vh;border-radius: 8px;box-shadow: rgba(0, 0, 0, 0.3) 0px 8px 24px;transform: scale(1);transition: transform 0.3s;} .cktp i {padding-top: 2px;} /* .cktp i {display: grid;} .cktp i { background-size: contain; width: 16px; height: 16px; background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xOS42MTM3IDEwLjMwMTJDMTkuNjkzMiAxMC4xMDg0IDE5LjY5MzIgOS44OTI4MiAxOS42MTM3IDkuNzAwMDRDMTkuNTc0MyA5LjYwMzkzIDE5LjUxNjUgOS41MTcyNiAxOS40NDQzIDkuNDQ1MDRMMTcuMjIyMSA3LjIyMjgyQzE2LjkxNDggNi45MTU2IDE2LjQxNzYgNi45MTYxNSAxNi4xMTEgNy4yMjI4MkMxNS44MDQzIDcuNTI5NDggMTUuODAzNyA4LjAyNjcxIDE2LjExMSA4LjMzMzkzTDE2Ljk5MjEgOS4yMTUwNEw5Ljk5OTg1IDkuMjE1MDRDOS41NjU5NiA5LjIxNDQ5IDkuMjE0MjkgOS41NjYxNSA5LjIxNDI5IDEwLjAwMDZDOS4yMTQyOSAxMC4yMTczIDkuMzAyMDcgMTAuNDEzOSA5LjQ0NDI5IDEwLjU1NjJDOS41ODY1MSAxMC42OTg0IDkuNzgzMTggMTAuNzg2MiA5Ljk5OTg1IDEwLjc4NjJMMTYuOTkyMSAxMC43ODYyTDE2LjExMSAxMS42NjczQzE1LjgwNDMgMTEuOTczOSAxNS44MDM3IDEyLjQ3MTIgMTYuMTExIDEyLjc3ODRDMTYuNDE4MiAxMy4wODU2IDE2LjkxNTQgMTMuMDg1IDE3LjIyMjEgMTIuNzc4NEwxOS40NDQzIDEwLjU1NjJDMTkuNTE2NSAxMC40ODM5IDE5LjU3NDMgMTAuMzk3MyAxOS42MTM3IDEwLjMwMTJaIiBmaWxsPSIjNjE2NjZEIi8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMTMuODg4OSA2LjExMTExQzExLjc0MTMgMy45NjM0OSA4LjI1ODczIDMuOTYzNDkgNi4xMTExMSA2LjExMTExQzMuOTYzNDkgOC4yNTg3MyAzLjk2MzQ5IDExLjc0MTMgNi4xMTExMSAxMy44ODg5QzguMjU4NzMgMTYuMDM2NSAxMS43NDEzIDE2LjAzNjUgMTMuODg4OSAxMy44ODg5QzE0LjE5NTcgMTMuNTgyMSAxNC42OTMyIDEzLjU4MjEgMTUgMTMuODg4OUMxNS4zMDY4IDE0LjE5NTcgMTUuMzA2OCAxNC42OTMyIDE1IDE1QzEyLjIzODcgMTcuNzYxMyA3Ljc2MTI3IDE3Ljc2MTMgNSAxNUMyLjIzODczIDEyLjIzODcgMi4yMzg3MyA3Ljc2MTI3IDUgNUM3Ljc2MTI3IDIuMjM4NzMgMTIuMjM4NyAyLjIzODczIDE1IDVDMTUuMzA2OCA1LjMwNjgzIDE1LjMwNjggNS44MDQyOSAxNSA2LjExMTExQzE0LjY5MzIgNi40MTc5NCAxNC4xOTU3IDYuNDE3OTQgMTMuODg4OSA2LjExMTExWiIgZmlsbD0iIzYxNjY2RCIvPgo8L3N2Zz4K); }*/ `) let batchTimeout = null; var jc_room_id_list = GM_getValue('jc_room_id_list', []); var yc_room_id_list = GM_getValue('yc_room_id_list', ["1919214962","1710489753"]); // 电竞?陪玩? 还是聊天室√ 因为不在聊天室分区 特此添加 function 设置状态() { const bs = document.querySelectorAll('#card'); bs.forEach(b => { const href = b.getAttribute('href'); const room_id_match = href.match(/\/(\d+)\?/); let room_id; if (room_id_match) { room_id = room_id_match[1]; } else { console.error('无法从链接中提取room_id:', href); return; } if (jc_room_id_list.includes(room_id)) { b.setAttribute('data-test', 'true_0'); //b.parentElement.setAttribute('data-test', 'true_0'); } if (yc_room_id_list.includes(room_id)) { b.setAttribute('data-test', 'true_1'); //b.parentElement.setAttribute('data-test', 'true_1'); } }); console.log('设置状态一次'); } function 设置属性() { const as = document.querySelectorAll('#card'); as.forEach(a => { a.setAttribute('data-test', 'false'); }); console.log('初始化一次'); } function 检查b() { document.querySelectorAll('#card').forEach(card => { if (card.querySelector('[class^="Item_nickName_"]')?.textContent.includes("电竞")) { card.classList.add("DJ"); } }); } async function 检查() { const cards = document.querySelectorAll('#card[data-test="false"]'); let fetchPromises = []; cards.forEach(card => { const href = card.getAttribute('href'); const room_id_match = href.match(/\/(\d+)\?/); let room_id; if (room_id_match) {room_id = room_id_match[1];} else {console.error('无法从链接中提取room_id:', href);return;} if (!jc_room_id_list.includes(room_id) && !yc_room_id_list.includes(room_id)) { const params = new URLSearchParams({room_id: room_id}); const url = `https://api.live.bilibili.com/room/v1/Room/get_info?${params.toString()}`; fetchPromises.push( fetch(url, { method: 'GET', headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Edg/126.0.0.0' } }) .then(response => response.json()) .then(data => { if (data.data.parent_area_name === "聊天室") { console.warn('发现聊天室', room_id); if (!jc_room_id_list.includes(room_id)) {jc_room_id_list.push(room_id);} if (!yc_room_id_list.includes(room_id)) {yc_room_id_list.push(room_id);} } else { console.log('非聊天室:', room_id); if (!jc_room_id_list.includes(room_id)) {jc_room_id_list.push(room_id);} } }) .catch(error => { console.error('Error:', error); }) ); } }); await Promise.all(fetchPromises); GM_setValue('jc_room_id_list', jc_room_id_list); GM_setValue('yc_room_id_list', yc_room_id_list); console.log('储存一次'); 设置状态(); } function onElementAdded() { console.log('检测到 #room-card-list 增加了新元素!'); 设置属性(); 设置状态(); 检查(); 检查b() const roomCardList = document.querySelector('#room-card-list'); if (roomCardList) { console.log('当前子元素列表:', roomCardList.children); } } const observer = new MutationObserver((mutationsList) => { for (const mutation of mutationsList) { if (mutation.type === 'childList' && mutation.addedNodes.length > 0) { clearTimeout(batchTimeout); batchTimeout = setTimeout(onElementAdded, 800); } } }); const config = { childList: true, subtree: false }; function executeWithRetry(selector, action, retryInterval = 1500, maxRetries = 10) { let attempts = 0; const interval = setInterval(() => { const el = document.querySelector(selector); if (el) { clearInterval(interval); //可以把找到的元素传给 action //action(el); action(); } else if (++attempts >= maxRetries) { clearInterval(interval); console.log(`已达最大重试次数,${selector} 仍未找到。`); } else { console.log(`${selector}未找到 等待中...剩余重试次数:${maxRetries - attempts}`); } }, retryInterval); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 域名 const currentHostname = window.location.hostname; // 带协议域名 const baseUrl = window.location.origin; // 带参链接 const currentUrl = window.location.href; // 剔除参数 let url = currentUrl.split('?')[0]; // 参数 const search = window.location.search || ''; // 全路径 const path = window.location.pathname; // 剔除斜杠 const patha = path.substring(1); console.log("当前网址: ", currentUrl) // 直播 if (url === 'https://live.bilibili.com/' || /^https:\/\/live\.bilibili\.com\/\d+$/.test(url) || /^https:\/\/live\.bilibili\.com\/all/.test(url) || /^https:\/\/live\.bilibili\.com\/p\//.test(url) || /^https:\/\/link\.bilibili\.com\/p\//.test(url) ) { console.log("哔哩哔哩直播") // 直播顶栏 executeWithRetry('.live', () => { const targetLink = document.querySelector('.live'); if (targetLink) { console.log('✅ 已成功修改“直播”链接'); targetLink.href = "https://live.bilibili.com/all"; } /* setTimeout(() => { const updatedLink = document.querySelector('.live'); if (updatedLink.href === "https://live.bilibili.com/all") { console.log('✅ 链接验证成功,href 设置正确'); } else { console.error('❌ 链接验证失败,href 可能未正确设置'); updatedLink.href = "https://live.bilibili.com/all"; console.log('✅ 重新修改“直播”链接'); } }, 3000); */ }); // 全部直播间页 if (patha === 'all') { // 初始化 executeWithRetry('#card', () => { 设置属性(); 设置状态(); 检查(); 检查b() const roomCardList = document.querySelector('#room-card-list'); if (roomCardList) { observer.observe(roomCardList, config); console.log('已开始监听 #room-card-list 的变化...'); } else { console.error('#room-card-list 元素未找到!'); } }); } // 直播间 if (/^\d+$/.test(patha)) { console.log("房间号:" + patha); const newUrl = `${baseUrl}/blanc/${patha}${search}`; console.log("原版直播间:" + newUrl); const container = document.querySelector('.right-ctnr'); const returnDiv = document.createElement('div'); returnDiv.className = 'cktp'; returnDiv.title = '返回原版直播间'; const icon = document.createElement('i'); icon.innerHTML = `<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg" class="link-icon"> <path fill-rule="evenodd" clip-rule="evenodd" d="M17.6137 9.30115C17.6932 9.10837 17.6932 8.89282 17.6137 8.70004C17.5743 8.60393 17.5165 8.51726 17.4443 8.44504L15.2221 6.22282C14.9148 5.9156 14.4176 5.91615 14.111 6.22282C13.8043 6.52948 13.8037 7.02671 14.111 7.33393L14.9921 8.21504L7.99985 8.21504C7.56596 8.21448 7.21429 8.56615 7.21429 9.00059C7.21429 9.21726 7.30207 9.41393 7.44429 9.55615C7.58651 9.69837 7.78318 9.78615 7.99985 9.78615L14.9921 9.78615L14.111 10.6673C13.8043 10.9739 13.8037 11.4712 14.111 11.7784C14.4182 12.0856 14.9154 12.085 15.2221 11.7784L17.4443 9.55615C17.5165 9.48393 17.5743 9.39726 17.6137 9.30115" fill="var(--text2)"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M11.8889 5.11111C9.74127 2.96349 6.25873 2.96349 4.11111 5.11111C1.96349 7.25873 1.96349 10.7413 4.11111 12.8889C6.25873 15.0365 9.74127 15.0365 11.8889 12.8889C12.1957 12.5821 12.6932 12.5821 13 12.8889C13.3068 13.1957 13.3068 13.6932 13 14C10.2387 16.7613 5.76127 16.7613 3 14C0.238731 11.2387 0.23873 6.76127 3 4C5.76127 1.23873 10.2387 1.23873 13 4C13.3068 4.30683 13.3068 4.80429 13 5.11111C12.6932 5.41794 12.1957 5.41794 11.8889 5.11111Z" fill="var(--text2)"></path></svg> `; const textSpan = document.createElement('span'); //textSpan.textContent = '返回原版直播间'; returnDiv.appendChild(icon); returnDiv.appendChild(textSpan); returnDiv.addEventListener('click', () => { const roomId = path.match(/\d+/); if (roomId) { window.location.href = newUrl; } }); document.body.appendChild(returnDiv); } else { console.log("这不是一个有效的直播间页面"); } } // 正常顶栏 if ((currentHostname === 'www.bilibili.com' || currentHostname === 't.bilibili.com' || currentHostname === 'search.bilibili.com' || /^https:\/\/live\.bilibili\.com\/\d+$/.test(url)) && !currentUrl.startsWith("https://www.bilibili.com/correspond/")) { // 顶栏修改 console.log("顶栏修改", currentUrl); executeWithRetry('.header-entry-mini', () => { // 直播首页 → 全部直播间页 const targetLink = document.querySelector('.left-entry > li:nth-child(3) > a'); if (targetLink) { console.log('已成功修改“直播”链接'); targetLink.href = "https://live.bilibili.com/all"; } // 添加热门 const firstLi = document.querySelector('.left-entry > li:nth-child(2)'); if (firstLi) { const newLi = document.createElement('li'); newLi.className = 'v-popular-wrap'; newLi.innerHTML = '<a href="https://www.bilibili.com/v/popular/all/" target="_blank" class="default-entry"><span>热门</span></a>'; firstLi.parentNode.insertBefore(newLi, firstLi.nextSibling); console.log('已成功添加“热门”链接'); } else { console.error('未找到目标 <li> 元素!'); } }); } // 视频页面 if (currentUrl.startsWith("https://www.bilibili.com/video/")){ // 封面 const button = document.createElement('button'); button.className = 'cktp'; button.innerHTML = '<bili-icon icon="BDC/image_line/3" size="16"></bili-icon>'; button.title = '点击预览图片'; document.body.appendChild(button); const previewContainer = document.createElement('div'); previewContainer.className = 'cktpa'; const previewImg = document.createElement('img'); previewContainer.appendChild(previewImg); previewContainer.addEventListener('click', (e) => { if (e.target === previewContainer) { previewContainer.style.display = 'none'; } }); previewImg.addEventListener('click', () => { if (previewImg.style.transform === 'scale(1.5)') { previewImg.style.transform = 'scale(1)'; previewImg.style.transition = 'transform 0.3s'; } else { previewImg.style.transform = 'scale(1.5)'; previewImg.style.transition = 'transform 0.3s'; } }); document.body.appendChild(previewContainer); const img = document.getElementById('wxwork-share-pic'); let currentSrc = img.src; Object.defineProperty(img, 'src', { configurable: false, enumerable: true, get() { return currentSrc; }, set(newSrc) { if (newSrc !== currentSrc) { currentSrc = newSrc; previewImg.src = newSrc; } } }); previewImg.src = currentSrc; button.addEventListener('click', () => { if (previewImg.src) { previewContainer.style.display = 'flex'; } }); } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址