知乎直达 Block Bottom Navigation Bar

在手机版搜索页面屏蔽知乎智答底部导航栏,在其他页面展示

  1. // ==UserScript==
  2. // @name 知乎直达 Block Bottom Navigation Bar
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description 在手机版搜索页面屏蔽知乎智答底部导航栏,在其他页面展示
  6. // @icon https://pica.zhimg.com/v2-79e835d86b026c7c499de99d49906814.png
  7. // @author qianjunlang
  8. // @match *://zhida.zhihu.com/*
  9. // @grant none
  10. // @license MIT
  11. // @run-at document-start
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // 创建并添加CSS样式
  18. function addCustomStyle() {
  19. // 检查是否已经添加了样式
  20. if (document.getElementById('block-bottom-nav-style')) {
  21. return;
  22. }
  23.  
  24. const style = document.createElement('style');
  25. style.id = 'block-bottom-nav-style';
  26. style.textContent = `
  27.  
  28. #fullScreen > div:nth-child(1) > div > div:nth-child(2) > div:nth-child(1) > div > div.css-175oi2r.r-1loqt21.r-1otgn73 > svg path
  29. {
  30. fill: #F7971D !important;
  31. }
  32. #fullScreen > div:nth-child(1) > div > div:nth-child(2) > div:nth-child(1) > div > div:nth-child(2) > div.css-175oi2r.r-1loqt21.r-1otgn73 > div,
  33. #fullScreen > div:nth-child(1) > div > div:nth-child(2) > div:nth-child(1) > div > div:nth-child(2) > div:nth-child(2) > div > div > div > div
  34. {
  35. opacity: 0.5 !important;
  36. }
  37.  
  38. /* 只在body带有特定class时隐藏底部导航栏 */
  39. body.hide-nav-bar div.css-175oi2r[style*="height: 58px"][style*="box-shadow: rgba(88, 92, 103, 0.08) 0px 0px 24px"]
  40. {
  41. display: none !important;
  42. visibility: hidden !important;
  43. opacity: 0 !important;
  44. pointer-events: none !important;
  45. height: 0 !important;
  46. }
  47. /* 顶部导航栏样式 - 在搜索页面缩小高度 */
  48. body.hide-nav-bar div.css-175oi2r[style*="box-shadow: rgba(88, 92, 103, 0.08) 0px 1px 0px"][style*="height: 52px"] {
  49. height: 28px !important;
  50. border-bottom: 1px solid rgba(88, 92, 103, 0.2);
  51. }
  52. body.hide-nav-bar #fullScreen > div:nth-child(1) > div > div:nth-child(2) > div:nth-child(1) > div > div.css-175oi2r.r-1loqt21.r-1otgn73 > div {
  53. transform: scale(0.8); /* 缩小到80%,您可以调整这个值 */
  54. transform-origin: center; /* 控制缩放的起点 */
  55. }
  56.  
  57. /*deepseek button*/
  58. body.hide-nav-bar #fullScreen > div:nth-child(1) > div > div:nth-child(2) > div:nth-child(3) > div.css-175oi2r.r-150rngu.r-18u37iz.r-16y2uox.r-1wbh5a2.r-lltvgl.r-buy8e9.r-agouwx {
  59. justify-content: flex-end !important;
  60. position: relative;
  61. height: 20px;
  62. }
  63. body.hide-nav-bar #fullScreen > div:nth-child(1) > div > div:nth-child(2) > div:nth-child(3) > div.css-175oi2r.r-150rngu.r-18u37iz.r-16y2uox.r-1wbh5a2.r-lltvgl.r-buy8e9.r-agouwx > div {
  64.  
  65. gap: 0px !important;
  66. margin-bottom: 3px !important;
  67. transform: scale(0.8);
  68. transform-origin: bottom right;
  69. z-index: 1000;
  70. }
  71. body.hide-nav-bar #fullScreen > div:nth-child(1) > div > div:nth-child(2) > div:nth-child(2) > div.css-175oi2r.r-1loqt21.r-1otgn73{
  72. display:none;
  73. }
  74.  
  75.  
  76.  
  77. `;
  78. document.head.appendChild(style);
  79. }
  80.  
  81. // 检查当前URL是否匹配条件
  82. function checkUrlAndApply() {
  83. // 确保样式已添加
  84. addCustomStyle();
  85.  
  86. if (
  87. window.location.pathname.includes('/search/') ||
  88. window.location.pathname.endsWith('/history')
  89. ) {
  90. document.body.classList.add('hide-nav-bar');
  91.  
  92. } else {
  93. document.body.classList.remove('hide-nav-bar');
  94. }
  95. }
  96.  
  97. // 监听URL变化(处理SPA应用)
  98. function setupUrlChangeListener() {
  99. // 使用history API监听
  100. const originalPushState = history.pushState;
  101. const originalReplaceState = history.replaceState;
  102.  
  103. history.pushState = function() {
  104. originalPushState.apply(this, arguments);
  105. checkUrlAndApply();
  106. };
  107.  
  108. history.replaceState = function() {
  109. originalReplaceState.apply(this, arguments);
  110. checkUrlAndApply();
  111. };
  112.  
  113. // 监听popstate事件(后退/前进按钮)
  114. window.addEventListener('popstate', checkUrlAndApply);
  115.  
  116. // 监听hashchange事件
  117. window.addEventListener('hashchange', checkUrlAndApply);
  118. }
  119.  
  120. function initialize() {
  121. // 等待body元素加载完成
  122. if (!document.body) {
  123. window.addEventListener('DOMContentLoaded', () => {
  124. // 立即检查当前URL
  125. checkUrlAndApply();
  126.  
  127. // 设置URL变化监听
  128. setupUrlChangeListener();
  129. });
  130. } else {
  131. // 立即检查当前URL
  132. checkUrlAndApply();
  133.  
  134. // 设置URL变化监听
  135. setupUrlChangeListener();
  136. }
  137. }
  138.  
  139. // DOM完全加载后执行
  140. if (document.readyState === 'loading') {
  141. document.addEventListener('DOMContentLoaded', initialize);
  142. } else {
  143. initialize();
  144. }
  145. // 页面完全加载后再次检查
  146. window.addEventListener('load', checkUrlAndApply);
  147.  
  148. })();

QingJ © 2025

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