您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
哔哩哔哩(首页) - 页面变窄时隐藏活动和栏目
当前为
// ==UserScript== // @name Bilibili Evolved 强化辅助 (非 Bilibili Evolved 本体) // @namespace Ninkror // @version 1.0 // @author Ninkror // @description 哔哩哔哩(首页) - 页面变窄时隐藏活动和栏目 // @description 哔哩哔哩(播放页) - 页面清理 | 自动播放下一个视频 | 展开视频介绍 | 展开视频标签 // @description 哔哩哔哩(动态页) - 侧栏调整 | 隐藏其他分组番剧 | 无显示动态时自动刷新 // @description 哔哩哔哩(空间页) - 显示舰长数 // @description 哔哩哔哩(直播间) - 页面清理 | 弹幕设置浮窗置顶 | 显示高能用户数 | 底栏高度对齐 | 顶栏UP主名字全部显示 // @match https://live.bilibili.com/* // @match https://space.bilibili.com/* // @match https://t.bilibili.com/* // @match https://www.bilibili.com/* // @icon https://www.bilibili.com/favicon.ico // @grant GM_addStyle // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @license MIT // ==/UserScript== function autoHide() { setInterval(function () { var div1 = document.querySelector('.fresh-home-content-layout > div:nth-child(1)'); var div2 = document.querySelector('.fresh-home-content-layout > div:nth-child(5)'); if (document.querySelector('body').clientWidth <= 800) { div1.style = 'display:none'; div2.style = 'display:none'; } else { div1.removeAttribute('style'); div2.removeAttribute('style'); } }, 1000); } function sidebarAdjust() { GM_addStyle('.bili-dyn-live-users__body {max-height: calc(100vh - 150px) !important}'); GM_addStyle('#btf-tab-area {padding: 0px 0px 0px !important}'); GM_addStyle('#btf-bwlist-area {padding-top: 0px !important; padding-bottom: 8px !important}'); var left = document.querySelector('aside.left'); var right = document.querySelector('aside.right'); new ElementGetter().get('.feeds-filter-section', document, 10000).then((dynFilter) => { new ElementGetter().get('#btf-bwlist-area', document, 10000).then((advSel) => { new ElementGetter().get('.bili-dyn-my-info', document, 10000).then((userInfo) => { new ElementGetter().get('.bili-dyn-live-users', document, 10000).then((liveList) => { left.appendChild(dynFilter); left.appendChild(advSel); left.appendChild(userInfo); right.appendChild(liveList); }); }); }); }); } function animeHide() { var hide = GM_addStyle(''); setInterval(function () { var a = document.querySelector('.bili-dyn-list-tabs__item.active'); var b = document.querySelector('.van-tab.van-tab--active'); if (a.textContent == '\n 全部\n ' && b.textContent != '全部') { hide.textContent = '[data-type="512"] {display: none}'; } else { hide.textContent = ''; } }, 500); } function autoRefresh() { setInterval(function () { if (document.querySelector('.bili-dyn-list__items').clientHeight == 0) { window.scrollTo({ top: document.body.clientHeight }); window.scrollTo({ top: 0 }); } }, 500); } function liveRoomClean() { const blockList = [ '#gift-control-vm', //礼物栏 '#link-footer-vm', //底部 '#right-part > div:nth-child(2) > div:nth-child(3)', //顶栏右侧 饭贩 '#right-part > div:nth-child(2) > div:nth-child(4)', //顶栏右侧 我要开播 '#shop-popover-vm', //小橙车 弹窗 '#sidebar-vm', //右下角 浮窗 '.activity-gather-entry', //播放器顶栏 UP主名字左侧 再左侧 '.gift-planet-entry', //播放器顶栏 UP主名字左侧 '.right-ctnr > div:nth-child(3)', //播放器顶栏 举报 '.right-ctnr > div:nth-child(4)', //播放器顶栏 分享 '.room-feed', //UP主动态 '.web-player-icon-feedback', //播放器 右上角 反馈 ]; GM_addStyle(blockList.join(', ') + '{display: none !important}'); } function settingTop() { GM_addStyle(` .dialog-ctnr { z-index: 9999 !important; } `); } function showPayUser() { const getInfoByRoom = "https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom" const getOnlineGoldRank = "https://api.live.bilibili.com/xlive/general-interface/v1/rank/getOnlineGoldRank" new ElementGetter().get('.tab-list > .live-skin-main-text').then((item) => { const rid = window.location.pathname.split('/').pop(); GM_xmlhttpRequest({ method: 'get', url: `${getInfoByRoom}?room_id=${rid}`, onload: function (res) { if (res.status === 200) { const resJson = JSON.parse(res.response); if (resJson['code'] === 0) { const uid = resJson['data']['room_info']['uid']; setInterval(function () { GM_xmlhttpRequest({ method: 'get', url: `${getOnlineGoldRank}?ruid=${uid}&roomId=${rid}&page=1000&pageSize=1000`, onload: function (res) { if (res.status === 200) { const resJson = JSON.parse(res.response); if (resJson['code'] === 0) { const userNum = resJson['data']['onlineNum']; item.textContent = '高能用户(' + userNum + ')'; } } }, }); }, 2000); } } }, }); }); } function bottomHeightAdjust() { new ElementGetter().get('.room-info-ctnr > div').then((left) => { if (document.querySelector('.room-introduction-scroll-wrapper')) { document.querySelector('.room-introduction-scroll-wrapper').removeAttribute('class'); } var right = document.querySelector('.right-container > div'); if (right != null) { var leftHeight = left.clientHeight; var rightHeight = right.clientHeight; if (leftHeight + 48 > rightHeight) { right.style.height = leftHeight + 16 + 'px'; } else if (leftHeight < rightHeight) { if (document.querySelector('.room-introduction-tags')) { left.style.height = rightHeight - 96 + 'px'; } else { left.style.height = rightHeight - 48 + 'px'; } } } }); } function showFullName() { GM_addStyle(` .room-owner-username { max-width: 200px !important; } `); } function showShip() { const spaceUrl = 'https://api.bilibili.com/x/space/acc/info'; const roomUrl = 'https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom'; const uid = window.location.pathname.split('/')[1]; new ElementGetter().each('.i-live-fo-count.space-fans', document, (item) => { GM_xmlhttpRequest({ method: 'get', url: `${spaceUrl}?mid=${uid}`, onload: function (res) { if (res.status === 200) { const resJson = JSON.parse(res.response); if (resJson['code'] === 0) { const roomid = resJson['data']['live_room']['roomid']; GM_xmlhttpRequest({ method: 'get', url: `${roomUrl}?room_id=${roomid}`, onload: function (res) { if (res.status === 200) { const resJson = JSON.parse(res.response); if (resJson['code'] === 0) { const num = resJson['data']['guard_info']['count']; item.textContent = `${num}🚢`; } } }, }); } } }, }); }); } function videoClean() { const blockElement = [ '#arc_toolbar_report > .more', //视频下方功能区 更多 '#arc_toolbar_report > .ops > .share', //视频下方功能区 分享 '#arc_toolbar_report > .rigth-btn', //视频下方功能区 右侧 '#v_desc > .tip-info', //版权提示 '.bpx-player-dm-hint', //弹幕发送栏 弹幕礼仪 '.float-nav__btn--fixed', //浮窗 前往新版 '.float-nav > .nav-menu > [title="帮助反馈"]', //浮窗 客服 ]; GM_addStyle(blockElement.join(', ') + '{display:none!important}'); } function videoCleanN() { const blockElement_new = [ // '#playlistToolbar > .video-toolbar-left > div:has(.video-share-wrap)', //视频下方功能区 分享 '.float-nav-exp > div > a[title="帮助反馈"]', //浮窗 客服 '.reply-header > .reply-notice', //评论区顶端横幅 '.video-toolbar-right', //视频下方功能区 右侧 ]; GM_addStyle(blockElement_new.join(', ') + '{display:none!important}'); } function autoNextVideoN() { new ElementGetter().each('.bpx-player-ending-functions-btn[data-action="restart"]', document, (restart) => { var next = document.querySelector('.bpx-player-ctrl-btn.bpx-player-ctrl-next'); if (next == undefined) { return false; } next.click(); }); } function showMoreIntro() { new ElementGetter().get('.toggle-btn', document).then((btn) => { btn.click(); }); } function showMoreTag() { new ElementGetter().get('.show-more-btn', document).then((btn) => { btn.click(); }); } const mainPage = window.location.href == 'https://www.bilibili.com/'; const dynamic = window.location.host == 't.bilibili.com'; const liveRoom = window.location.href.match(/https:\/\/live\.bilibili\.com\/[0-9]+/) != null; const space = window.location.href.match(/https:\/\/space\.bilibili\.com\/[0-9]+/) != null; const video = window.location.href.match(/https:\/\/www\.bilibili\.com\/(list)|(video)/) != null; const funcList = [ { name: 'autoHide', menu: '页面变窄时隐藏活动和栏目', match: mainPage, func: autoHide, }, { name: 'sidebarAdjust', menu: '侧栏调整', match: dynamic, func: sidebarAdjust, }, { name: 'animeHide', menu: '隐藏其他分组的番剧', match: dynamic, func: animeHide, }, { name: 'autoRefresh', menu: '无显示动态时自动刷新', match: dynamic, func: autoRefresh, }, { name: 'liveRoomClean', menu: '页面清理', match: liveRoom, func: liveRoomClean, }, { name: 'settingTop', menu: '弹幕设置弹窗置顶', match: liveRoom, func: settingTop, }, { name: 'showPayUser', menu: '显示高能用户数', match: liveRoom, func: showPayUser, }, { name: 'bottomHeightAdjust', menu: '底栏高度对齐', match: liveRoom, func: bottomHeightAdjust, }, { name: 'showFullName', menu: '顶栏UP主名字全部显示', match: liveRoom, func: showFullName, }, { name: 'showShip', menu: '显示舰长数', match: space, func: showShip, }, { name: 'videoClean', menu: '播放页清理', match: video, func: videoClean, }, { name: 'videoCleanN', menu: '播放页清理(新播放页)', match: video, func: videoCleanN, }, { name: 'autoNextVideoN', menu: '自动播放下一个视频(新播放页)', match: video, func: autoNextVideoN, }, { name: 'showMoreIntroN', menu: '展开视频介绍(新播放页)', match: video, func: showMoreIntro, }, { name: 'showMoreTagN', menu: '展开视频标签(新播放页)', match: video, func: showMoreTag, }, ]; funcList.forEach((item) => { if (item.match) { var name = item.name; var menu = item.menu; if (GM_getValue(name) == undefined) { GM_setValue(name, true); } var open = GM_getValue(name); GM_registerMenuCommand(`${open ? '✅' : '❌'}${menu} - ${name}`, function () { GM_setValue(name, !open); window.location.reload(); }); if (open) { item.func(); console.log(`${name} - ${menu} - 已开启`); } } });