bilibili净化

bilibili净化脚本,屏蔽各种不需要的页面元素、关键字、直播、广告

  1. // ==UserScript==
  2. // @name bilibili净化
  3. // @namespace evalcony
  4. // @version 0.4.5
  5. // @description bilibili净化脚本,屏蔽各种不需要的页面元素、关键字、直播、广告
  6. // @author evalcony
  7. // @match https://*.bilibili.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
  9. // @grant none
  10. // @license MIT
  11. // @homepageURL https://github.com/evalcony/better-bilibili
  12. // ==/UserScript==
  13. (() => {
  14. 'use strict';
  15. new MutationObserver(() => {
  16. // 首页 屏蔽词 list
  17. var blackList = [
  18. // 首页屏蔽关键字 示例
  19. '对局','页游','国服','国标','破防','好看','好听','打野','逆风','射手','下头','戒','女朋友',
  20. ];
  21. // 个人动态页面 屏蔽词 list
  22. var dynBlackList = [
  23. // 个人动态页屏蔽关键字 示例
  24. '进口','转+评','拼多多','精美','券后','版型','官方店','库存','先拍','预告','治愈','投票','公示','VLOG','好货','实习生',
  25. '直播','猫咪','党校','转发有奖','巡礼','预约','分享动态','恭喜','中奖','甄别','还有谁','炎热','万粉','手气','封面',
  26. '即将','泰裤辣','安康','不见不散','分享视频','福利','转发','里程碑','UP主','快乐','按摩','冲牙器','实惠','便宜','豪礼',
  27. '到手','内裤','好好选'
  28. ];
  29.  
  30. // 动态、热门、频道
  31. const channelIconsElement = document.querySelector('div.channel-icons');
  32. if (channelIconsElement) {
  33. channelIconsElement.remove();
  34. }
  35. const channelFixedLeftElement = document.querySelector('div.header-channel-fixed-left');
  36. if (channelFixedLeftElement) {
  37. channelFixedLeftElement.remove();
  38. }
  39. // 导航栏右侧
  40. const channelRightElement = document.querySelector('a.channel-link__right');
  41. if (channelRightElement) {
  42. channelRightElement.remove();
  43. }
  44. // 推荐
  45. const recommendedSwipeElement = document.querySelector('div.recommended-swipe.grid-anchor');
  46. if (recommendedSwipeElement) {
  47. recommendedSwipeElement.remove();
  48. }
  49. // // grid
  50. // const videoCardSkeletonElement = document.querySelector('div.bili-video-card__skeleton');
  51. // if (videoCardSkeletonElement) {
  52. // videoCardSkeletonElement.remove();
  53. // }
  54. // // grid封面
  55. // const cardImageElement = document.querySelector('div.bili-video-card__image.__scale-player-wrap');
  56. // if (cardImageElement) {
  57. // cardImageElement.remove();
  58. // }
  59. // 直播card
  60. const floorCardSingleCardElement = document.querySelector('div.floor-card.single-card');
  61. if (floorCardSingleCardElement) {
  62. floorCardSingleCardElement.remove();
  63. }
  64. // 直播card 带有直播标签的视频
  65. //class="bili-live-card is-rcmd"
  66. const liveCardElement = document.querySelector('div.bili-live-card');
  67. if (liveCardElement) {
  68. liveCardElement.remove();
  69. }
  70. // 点赞数量标签
  71. const videoCardInfoIconTextElement = document.querySelector('div.bili-video-card__info--icon-text');
  72. if (videoCardInfoIconTextElement) {
  73. videoCardInfoIconTextElement.remove();
  74. }
  75. // 页面滑动板块
  76. const channelSwiperElement = document.querySelector('div.channel-swiper.channel-swiper-client');
  77. if (channelSwiperElement) {
  78. channelSwiperElement.remove();
  79. }
  80. // 热门
  81. const asideWrapElement = document.querySelector('div.aside-wrap');
  82. if (asideWrapElement) {
  83. asideWrapElement.remove();
  84. }
  85.  
  86. // 根据屏蔽词过滤grid
  87. const cardInfoElementList = document.querySelectorAll('div.bili-video-card')
  88. if (cardInfoElementList) {
  89. var max_len = 20
  90. cardInfoElementList.forEach(card => {
  91. // var links = card.getElementsByTagName('a')
  92. var videoCardInfoRight = card.querySelector('div.bili-video-card__info--right')
  93. if (videoCardInfoRight) {
  94. var links = videoCardInfoRight.getElementsByTagName('a')
  95. if (links) {
  96. for (var i = 0; i < links.length; i++) {
  97. var title = links[i].textContent || links[i].innerText;
  98. var flag = false;
  99. for (var j = 0; j < blackList.length; ++j) {
  100. if (title.indexOf(blackList[j]) !== -1) {
  101. console.log("屏蔽词:" + blackList[j] + " title=" + title);
  102. flag = true;
  103. break;
  104. }
  105. }
  106. if (flag) {
  107. card.remove();
  108. break;
  109. }
  110. // 标题缩减
  111. if (title.length > max_len) {
  112. links[i].innerHTML = title.substring(0, max_len)
  113. }
  114. }
  115. }
  116. }
  117. // 广告
  118. var svg = card.querySelector('svg.bili-video-card__info--ad')
  119. if (svg) {
  120. card.remove();
  121. }
  122.  
  123. })
  124. }
  125.  
  126.  
  127. //--------------------------
  128. // 删除动态搜索栏的占位文字
  129. const navSearchInputElement = document.querySelector('input.nav-search-input')
  130. if (navSearchInputElement) {
  131. navSearchInputElement.removeAttribute('placeholder');
  132. navSearchInputElement.removeAttribute('title');
  133. }
  134. // 删除搜索历史
  135. const searchPanelElement = document.querySelector('div.search-panel');
  136. if (searchPanelElement) {
  137. searchPanelElement.remove();
  138. }
  139. // 菜单栏
  140. const leftEntryElement = document.querySelector('ul.left-entry');
  141. if (leftEntryElement) {
  142. //leftEntryElement.remove();
  143. }
  144. // 右边菜单栏
  145. const rightEntryVipElement = document.querySelector('a.right-entry__outside.right-entry--vip');
  146. if (rightEntryVipElement) {
  147. rightEntryVipElement.remove();
  148. }
  149. // 右边菜单栏-个人消息
  150. const rightEntryMessageElement = document.querySelector('li.v-popover-wrap.right-entry__outside.right-entry--message');
  151. if (rightEntryMessageElement) {
  152. //rightEntryMessageElement.remove();
  153. }
  154.  
  155. const headerUploadEntryElement = document.querySelector('div.header-upload-entry');
  156. if (headerUploadEntryElement) {
  157. headerUploadEntryElement.remove();
  158. }
  159.  
  160. // up头像
  161. const upAvatarElement = document.querySelector('div.up-avatar-wrap');
  162. if (upAvatarElement) {
  163. upAvatarElement.remove();
  164. }
  165. // 充电
  166. const chargeBtnElement = document.querySelector('div.default-btn.new-charge-btn.charge-btn-loaded');
  167. if (chargeBtnElement) {
  168. chargeBtnElement.remove();
  169. }
  170.  
  171. // //删除视频弹幕发送
  172. //const videoPlayerSendingElement = document.querySelector('div.bpx-player-sending-bar');
  173. //if (videoPlayerSendingElement) {
  174. //videoPlayerSendingElement.remove();
  175. //}
  176.  
  177. // 投诉
  178. const videoComplaintElement = document.querySelector('div.video-toolbar-right-item.toolbar-right-complaint');
  179. if (videoComplaintElement) {
  180. videoComplaintElement.remove();
  181. }
  182. // 笔记
  183. const videoNoteElement = document.querySelector('div.video-note.video-toolbar-right-item.toolbar-right-note');
  184. if (videoNoteElement) {
  185. videoNoteElement.remove();
  186. }
  187. // share
  188. const videoShareBtnElement = document.querySelector('div.video-share-wrap.video-toolbar-left-item');
  189. if (videoShareBtnElement) {
  190. videoShareBtnElement.remove();
  191. }
  192. // 下方
  193. const leftContainerUnderPlayerElement = document.querySelector('div.left-container-under-player');
  194. if (leftContainerUnderPlayerElement) {
  195. //leftContainerUnderPlayerElement.remove();
  196. }
  197. //删除视频下方标签
  198. const tagWrapElement = document.querySelector('div.tag-wrap');
  199. if (tagWrapElement) {
  200. tagWrapElement.remove();
  201. }
  202. // 广告
  203. const adReportElement = document.querySelector('div.ad-floor-cover.b-img');
  204. if (adReportElement) {
  205. adReportElement.remove();
  206. }
  207. // 直播
  208. const popLivePartElement = document.querySelector('div.pop-live-small-mode.part-undefined');
  209. if (popLivePartElement) {
  210. popLivePartElement.remove();
  211. }
  212. // 评论区
  213. const commentElement = document.querySelector('.comment');
  214. if (commentElement) {
  215. //commentElement.remove();
  216. }
  217.  
  218. // 右侧上方广告
  219. const slideGgElement = document.querySelector('.slide-gg');
  220. if (slideGgElement) {
  221. slideGgElement.remove();
  222. }
  223.  
  224. // 右侧广告
  225. const slideAdElement = document.querySelector('.slide_ad');
  226. if (slideAdElement) {
  227. slideAdElement.remove();
  228. }
  229.  
  230. // 右侧直播推荐
  231. const popLiveSmallModeElement = document.querySelector('.pop-live-small-mode');
  232. if (popLiveSmallModeElement) {
  233. popLiveSmallModeElement.remove();
  234. }
  235. // 说明:bibili 这里做了关联,屏蔽了推荐列表,会导致选集列表数据无法展示,所以要屏蔽就都屏蔽
  236. // 这里改动这里的 false / true 即可
  237. // false: 不屏蔽
  238. // true: 屏蔽
  239. // 推荐设置为 false。
  240. if (false) {
  241. // 右侧视频选集列表
  242. const videoPageCardElement = document.querySelector('#multi_page');
  243. if (videoPageCardElement) {
  244. videoPageCardElement.remove();
  245. }
  246. // 右侧视频推荐列表
  247. const recommendListElement = document.querySelector('.recommend-list-v1');
  248. if (recommendListElement) {
  249. recommendListElement.remove();
  250. }
  251. }
  252.  
  253. // 视频播放中出现的问题面板
  254. const bpxPlayerCmdDmElement = document.querySelector('.bpx-player-cmd-dm-inside');
  255. if (bpxPlayerCmdDmElement) {
  256. bpxPlayerCmdDmElement.remove();
  257. }
  258.  
  259.  
  260. //-------------------------- 动态
  261.  
  262. // 个人动态
  263. const biliDynItemsList = document.querySelectorAll('div.bili-dyn-item__main');
  264. if (biliDynItemsList) {
  265. biliDynItemsList.forEach(item => {
  266. // 投票
  267. var voteElement = item.querySelector('.bili-dyn-card-vote__body')
  268. if (voteElement) {
  269. console.log('屏蔽投票')
  270. item.remove();
  271. return;
  272. }
  273.  
  274. // 预约
  275. var reserveElement = item.querySelector('.bili-dyn-card-reserve')
  276. if (reserveElement) {
  277. console.log('屏蔽预约')
  278. item.remove();
  279. return;
  280. }
  281.  
  282. // 正文
  283. var richTextContent = item.querySelector('div.bili-rich-text__content')
  284. if (richTextContent) {
  285. var textElementList = richTextContent.getElementsByTagName('span')
  286. if (textElementList) {
  287. for (var i = 0; i < textElementList.length; i++) {
  288. var text = textElementList[i].textContent || textElementList[i].innerText;
  289. var flag = false;
  290. for (var j = 0; j < dynBlackList.length; ++j) {
  291. if (text.indexOf(dynBlackList[j]) !== -1) {
  292. console.log("包含指定字符串:" + dynBlackList[j]);
  293. flag = true;
  294. break;
  295. }
  296. }
  297. if (flag) {
  298. item.remove();
  299. break;
  300. }
  301. }
  302. }
  303. }
  304.  
  305. // 转发、评论、点赞
  306. var itemFooterElement = item.querySelector('.bili-dyn-item__footer')
  307. if (itemFooterElement) {
  308. //itemFooterElement.remove();
  309. return;
  310. }
  311. })
  312. }
  313.  
  314. // 右侧话题栏
  315. const biliDynTopicBoxElement = document.querySelector('.bili-dyn-topic-box');
  316. if (biliDynTopicBoxElement) {
  317. biliDynTopicBoxElement.remove();
  318. }
  319. // 右侧话题栏banner
  320. const dynBannerElement = document.querySelector('.bili-dyn-banner');
  321. if (dynBannerElement) {
  322. dynBannerElement.remove();
  323. }
  324.  
  325.  
  326. // --------------- 直播间
  327. // 直播房间-礼物栏
  328. const giftControlPanelElement = document.querySelector('.gift-control-panel');
  329. if (giftControlPanelElement) {
  330. giftControlPanelElement.remove();
  331. }
  332.  
  333. // 直播房间-视频下方区域
  334. const sectionBlockElement = document.querySelector('.section-block');
  335. if (sectionBlockElement) {
  336. sectionBlockElement.remove();
  337. }
  338. // 直播房间-视频上方信息区
  339. const headInfoLowerRowElement = document.querySelector('.head-info-section .lower-row');
  340. if (headInfoLowerRowElement) {
  341. headInfoLowerRowElement.remove();
  342. }
  343. // 直播房间-页面底部bilibili公司信息区域
  344. const linkFooterElement = document.querySelector('#link-footer-vm');
  345. if (linkFooterElement) {
  346. linkFooterElement.remove();
  347. }
  348. // 直播房间-bilibili娘
  349. const harunaElement = document.querySelector('.haruna-ctnr');
  350. if (harunaElement) {
  351. harunaElement.remove();
  352. }
  353. // 直播房间-pk
  354. const awesomePkBoxElement = document.querySelector('.awesome-pk-box');
  355. if (awesomePkBoxElement) {
  356. awesomePkBoxElement.remove();
  357. }
  358. // 直播房间-pk
  359. const pkProcessBoxElement = document.querySelector('.pk-process-box');
  360. if (pkProcessBoxElement) {
  361. pkProcessBoxElement.remove();
  362. }
  363. // 直播房间-pk结果
  364. const pkAnimationBoxElement = document.querySelector('.pk-animation-box');
  365. if (pkAnimationBoxElement) {
  366. pkAnimationBoxElement.remove();
  367. }
  368. // 直播房间-横幅特效
  369. const announcementElement = document.querySelector('.announcement-wrapper');
  370. if (announcementElement) {
  371. announcementElement.remove();
  372. }
  373. // 直播房间-弹幕欢迎特效
  374. const bubbleListElement = document.querySelector('.bubble-list');
  375. if (bubbleListElement) {
  376. bubbleListElement.remove();
  377. }
  378. // 直播房间-粉丝牌
  379. const fansMedalItemElement = document.querySelector('.fans-medal-item-ctnr');
  380. if (fansMedalItemElement) {
  381. fansMedalItemElement.remove();
  382. }
  383. const wealthMedalElement = document.querySelector('.wealth-medal-ctnr');
  384. if (wealthMedalElement) {
  385. wealthMedalElement.remove();
  386. }
  387. const rankIconElement = document.querySelector('.rank-icon');
  388. if (rankIconElement) {
  389. rankIconElement.remove();
  390. }
  391. const titleLabelElement = document.querySelector('.title-label');
  392. if (titleLabelElement) {
  393. titleLabelElement.remove();
  394. }
  395. // 直播房间-舰长列表
  396. const rankListElement = document.querySelector('#rank-list-ctnr-box');
  397. if (rankListElement) {
  398. rankListElement.remove();
  399. }
  400. // 直播房间-小游戏
  401. const gameElement = document.querySelector('#game-id');
  402. if (gameElement) {
  403. gameElement.remove();
  404. }
  405.  
  406. }).observe(document.querySelector('body'), {
  407. childList: true,
  408. attributes: true,
  409. subtree: true,
  410. });
  411. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址