简化b站导航栏

点换一换会让页面上的那个广告再显示出来

  1. // ==UserScript==
  2. // @name 简化b站导航栏
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.14
  5. // @license GPL
  6. // @description 点换一换会让页面上的那个广告再显示出来
  7. // @author bahyqn
  8. // @match *://*.bilibili.com/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
  10. // @grant none
  11. // @note 2023-10-15-V0.14 重新改了下代码
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. 'use strict';
  16.  
  17. // Your code here...
  18.  
  19. function remove_index() {
  20.  
  21. let left_entry = document.getElementsByClassName('left-entry')[0].style.visibility = 'hidden';
  22. let right_entry = null;
  23. let time = setInterval(function () {
  24. right_entry = document.getElementsByClassName('bili-header__bar')[0].getElementsByClassName('right-entry')[0];
  25. if (right_entry != null) {
  26. let lis = right_entry.querySelectorAll('.v-popover-wrap');
  27. lis[1].style.display = 'none';
  28. lis[2].style.display = 'none';
  29. lis[3].style.display = 'none';
  30. clearInterval(time)
  31. }
  32. }, 200);
  33.  
  34. // 六个视频上的菜单
  35. var bili_header__channel = document.getElementsByClassName('bili-header__channel');
  36. bili_header__channel[0].remove();
  37.  
  38. var bili_layout = document.getElementsByClassName('feed2');
  39. bili_layout[0].style.marginTop = "2rem";
  40.  
  41. // 六个视频左边的那个窗口
  42. var recommended_swipe = document.getElementsByClassName('recommended-swipe grid-anchor');
  43. // console.log(recommended_swipe);
  44. recommended_swipe[0].remove();
  45.  
  46. var body = document.getElementsByClassName('feed-card');
  47. //console.log(body);
  48. remove_ad();
  49. }
  50.  
  51. function remove_ad(){
  52. var body = document.getElementsByClassName('feed-card');
  53. //console.log(body);
  54.  
  55. let flag = 0;
  56. for(let i = 0; i < body.length; i++){
  57. //body[i].style.marginTop = "2rem";
  58. let child = body[i].getElementsByClassName('bili-video-card is-rcmd');
  59. child = body[i].getElementsByClassName('bili-video-card is-rcmd');
  60. child = body[i].getElementsByClassName('bili-video-card__wrap __scale-wrap');
  61. child = body[i].getElementsByClassName('');
  62. child = body[i].getElementsByClassName('bili-video-card__info __scale-disable');
  63. child = body[i].getElementsByClassName('bili-video-card__info--right');
  64. child = body[i].getElementsByClassName('bili-video-card__info--bottom');
  65. child = body[i].getElementsByClassName('bili-video-card__info--ad');
  66.  
  67. if(child.length > 0){
  68. flag = i;
  69. }
  70. }
  71. body[flag].remove();
  72. }
  73.  
  74. function remove_video() {
  75.  
  76. let right_entry = null;
  77. let time = setInterval(function () {
  78. right_entry = document.getElementsByClassName('bili-header__bar')[0].getElementsByClassName('right-entry')[0];
  79. if (right_entry != null) {
  80. let left_entry = document.getElementsByClassName('left-entry')[0].style.visibility = 'hidden';
  81. let lis = right_entry.querySelectorAll('.v-popover-wrap');
  82. lis[1].style.display = 'none';
  83. lis[2].style.display = 'none';
  84. lis[3].style.display = 'none';
  85. clearInterval(time)
  86. }
  87. }, 200);
  88. }
  89.  
  90. function remove_other() {
  91. var li = document.getElementsByTagName('li');
  92. console.log('remove_other');
  93. console.log(li);
  94. for (let i = 0; i < 10; i++) {
  95. li[i].style.visibility = "hidden";
  96. }
  97.  
  98. let right_div = null;
  99. let time = setInterval(function () {
  100. right_div = document.getElementsByClassName('user-con signin').item(0);
  101. if (right_div != null) {
  102. let child = right_div.querySelectorAll('.item');
  103. console.log(child)
  104. for (let i = 1; i < 5; i++) {
  105. child[i].remove();
  106. }
  107. clearInterval(time);
  108. }
  109. }, 200);
  110. }
  111.  
  112. function remove_search() {
  113. // remove search
  114. let left_entry = document.getElementsByClassName('left-entry')[0].style.visibility = 'hidden';
  115. let right_entry = null;
  116. let time = setInterval(function () {
  117. right_entry = document.getElementsByClassName('bili-header__bar')[0].getElementsByClassName('right-entry')[0];
  118. if (right_entry != null) {
  119. let lis = right_entry.querySelectorAll('.v-popover-wrap');
  120. lis[1].style.display = 'none';
  121. lis[2].style.display = 'none';
  122. lis[3].style.display = 'none';
  123. clearInterval(time)
  124. }
  125. }, 200);
  126. }
  127.  
  128. window.onload = function () {
  129. let url_list = window.location.href.split('bilibili.com');
  130. console.log(url_list);
  131.  
  132. if (url_list[1].length <= 3) {
  133. remove_index();
  134. } else if (url_list[1].indexOf('all') == 1){
  135. remove_search();
  136. } else if (url_list[1].indexOf('video') == 1) {
  137. remove_video()
  138. } else {
  139. remove_other();
  140. }
  141. }
  142. }
  143.  
  144. )();

QingJ © 2025

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