百度文库界面清理

清除百度文库界面上多余节点,给你一个清爽的阅读环境

  1. // ==UserScript==
  2. // @name 百度文库界面清理
  3. // @namespace http://cesium.xin/
  4. // @version 0.1.2
  5. // @description 清除百度文库界面上多余节点,给你一个清爽的阅读环境
  6. // @author You
  7. // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js
  8. // @icon https://www.baidu.com/cache/icon/favicon.ico
  9. // @match http://wenku.baidu.com/*
  10. // @match https://wenku.baidu.com/*
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. var $ = window.jQuery;
  15.  
  16. $(document).ready(function(){
  17. 'use strict';
  18. $("head").append (
  19. '<link '
  20. + 'href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" '
  21. + 'rel="stylesheet" type="text/css">'
  22. );
  23. var content = document.getElementById('reader-wrap');
  24.  
  25. let divEle = document.getElementById('hqdiv');
  26. if(!divEle){
  27. var para = document.createElement("div");
  28. para.innerHTML = '<div style="position:fixed;left:10px;top:80px;width:55px;height:100px;z-index:999;" id="hqdiv"></div>';
  29. document.body.appendChild(para);
  30. $("#hqdiv").append('<ul id="hq-nav-bar" />');
  31. }
  32.  
  33. //添加子节点
  34. $("#hq-nav-bar").append('<li class="level-one" id="hqtrash"><i class="fa fa-trash"></i><ul class="level-two"><li>清理界面</li></ul></li> ');
  35.  
  36. document.getElementById("hqtrash").onclick = function() {
  37. //删除兄弟节点,删除父节点的兄弟节点
  38. removeBrother(content);
  39. //点击全屏按钮
  40. document.getElementsByClassName('full-screen')[0].click();
  41. //去掉浮动导航栏
  42. document.getElementsByClassName('fix-searchbar-wrap')[0].remove();
  43. };
  44.  
  45. function removeBrother(elm) {// ==UserScript==
  46. // @name 百度文库界面清理
  47. // @namespace http://cesium.xin/
  48. // @version 0.1.2
  49. // @description 清除百度文库界面上多余节点,给你一个清爽的阅读环境
  50. // @author You
  51. // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js
  52. // @icon https://www.baidu.com/cache/icon/favicon.ico
  53. // @match http://wenku.baidu.com/*
  54. // @match https://wenku.baidu.com/*
  55. // @grant none
  56. // ==/UserScript==
  57.  
  58. var $ = window.jQuery;
  59.  
  60. $(document).ready(function(){
  61. 'use strict';
  62. $("head").append (
  63. '<link '
  64. + 'href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" '
  65. + 'rel="stylesheet" type="text/css">'
  66. );
  67. var content = $('.reader-wrap')[0];
  68.  
  69. let divEle = document.getElementById('hqdiv');
  70. if(!divEle){
  71. var para = document.createElement("div");
  72. para.innerHTML = '<div style="position:fixed;left:10px;top:80px;width:55px;height:100px;z-index:999;" id="hqdiv"></div>';
  73. document.body.appendChild(para);
  74. $("#hqdiv").append('<ul id="hq-nav-bar" />');
  75. }
  76.  
  77. //添加子节点
  78. $("#hq-nav-bar").append('<li class="level-one" id="hqtrash"><i class="fa fa-trash"></i><ul class="level-two"><li>清理界面</li></ul></li> ');
  79.  
  80. document.getElementById("hqtrash").onclick = function() {
  81. //删除兄弟节点,删除父节点的兄弟节点
  82. removeBrother(content);
  83. //点击全屏按钮
  84. document.getElementsByClassName('full-screen')[0].click();
  85. //去掉浮动导航栏
  86. document.getElementsByClassName('fix-searchbar-wrap')[0].remove();
  87. };
  88.  
  89. function removeBrother(elm) {
  90. if (elm === null || elm.parentNode === null || elm === document.body) {
  91. return;
  92. }
  93. var p = elm.parentNode.children;
  94. for (var i = 0, pl = p.length; i < pl; i++) {
  95. if (p[i] !== elm && p[i].tagName.toLowerCase() !== "script"){
  96. p[i].innerHTML = "";
  97. }
  98. }
  99. removeBrother(elm.parentNode);
  100. }
  101.  
  102. function addGlobalStyle(css) {
  103. var head, style;
  104. head = document.getElementsByTagName('head')[0];
  105. if (!head) { return; }
  106. style = document.createElement('style');
  107. style.type = 'text/css';
  108. style.innerHTML = css;
  109. head.appendChild(style);
  110. }
  111. addGlobalStyle(`
  112. #hq-nav-bar {
  113. max-width: 50px;
  114. border: 1px solid #19A97B;
  115. border-radius: 4%;
  116. background-color: white;
  117. -webkit-box-shadow: -2px 3px 2px 0px rgba(5, 0, 0, 0.11);
  118. -moz-box-shadow: -2px 3px 2px 0px rgba(5, 0, 0, 0.11);
  119. box-shadow: -2px 3px 2px 0px rgba(5, 0, 0, 0.11);
  120. }
  121. #hq-nav-bar>li {
  122. color: white;
  123. margin: 0;
  124. font-family: 'Open Sans', sans-serif;
  125. font-size: 0.75em;
  126. list-style: none;
  127. }
  128. #hq-nav-bar>li.level-one {
  129. font-size: 1.5em;
  130. text-align: center;
  131. border-top: 1px solid #19A97B;
  132. cursor: pointer;
  133. }
  134. #hq-nav-bar>li.level-one:first-child {
  135. border-top: none;
  136. }
  137. #hq-nav-bar>li.level-one:hover {
  138. background: rgba(255,255,255,1);
  139. background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(233,238,242,1) 100%);
  140. background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(255,255,255,1)), color-stop(47%, rgba(246,246,246,1)), color-stop(100%, rgba(233,238,242,1)));
  141. background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(233,238,242,1) 100%);
  142. background: -o-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(233,238,242,1) 100%);
  143. background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(233,238,242,1) 100%);
  144. background: linear-gradient(to bottom, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(233,238,242,1) 100%);
  145. filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#e9eef2', GradientType=0 );
  146. }
  147. #hq-nav-bar>li.selected {
  148. background: #3f8eb9;
  149. -webkit-box-shadow: inset 1px 1px 10px 1px rgba(0,0,0,0.45);
  150. -moz-box-shadow: inset 1px 1px 10px 1px rgba(0,0,0,0.45);
  151. box-shadow: inset 1px 1px 10px 1px rgba(0,0,0,0.45);
  152. }
  153. #hq-nav-bar>li>i {
  154. color: #19A97B;
  155. margin: 25%;
  156. }
  157. .level-one {
  158. position: relative;
  159. }
  160. .level-two {
  161. display: none;
  162. position: absolute;
  163. height: 50px;
  164. width: 100px;
  165. background: #19A97B;
  166. border-radius: 4px;
  167. font-family: 'Open Sans', sans-serif;
  168. font-size: 0.65em;
  169. text-align: center;
  170. }
  171.  
  172. .level-two:after {
  173. content: '';
  174. position: absolute;
  175. border-style: solid;
  176. border-width: 9px 9px 9px 0;
  177. border-color: transparent #19A97B;
  178. display: block;
  179. width: 0;
  180. z-index: 1;
  181. left: -9px;
  182. top: 15px;
  183. }
  184.  
  185. .level-two li {
  186. margin: 15px;
  187. }
  188.  
  189. .level-one:hover > .level-two {
  190. display: block;
  191. }
  192.  
  193. .level-two {
  194. left: 130%;
  195. top: 0;
  196. }
  197. `);
  198. });
  199.  
  200. if (elm === null || elm.parentNode === null || elm === document.body) {
  201. return;
  202. }
  203. var p = elm.parentNode.children;
  204. for (var i = 0, pl = p.length; i < pl; i++) {
  205. if (p[i] !== elm && p[i].tagName.toLowerCase() !== "script"){
  206. p[i].innerHTML = "";
  207. }
  208. }
  209. removeBrother(elm.parentNode);
  210. }
  211.  
  212. function addGlobalStyle(css) {
  213. var head, style;
  214. head = document.getElementsByTagName('head')[0];
  215. if (!head) { return; }
  216. style = document.createElement('style');
  217. style.type = 'text/css';
  218. style.innerHTML = css;
  219. head.appendChild(style);
  220. }
  221. addGlobalStyle(`
  222. #hq-nav-bar {
  223. max-width: 50px;
  224. border: 1px solid #19A97B;
  225. border-radius: 4%;
  226. background-color: white;
  227. -webkit-box-shadow: -2px 3px 2px 0px rgba(5, 0, 0, 0.11);
  228. -moz-box-shadow: -2px 3px 2px 0px rgba(5, 0, 0, 0.11);
  229. box-shadow: -2px 3px 2px 0px rgba(5, 0, 0, 0.11);
  230. }
  231. #hq-nav-bar>li {
  232. color: white;
  233. margin: 0;
  234. font-family: 'Open Sans', sans-serif;
  235. font-size: 0.75em;
  236. list-style: none;
  237. }
  238. #hq-nav-bar>li.level-one {
  239. font-size: 1.5em;
  240. text-align: center;
  241. border-top: 1px solid #19A97B;
  242. cursor: pointer;
  243. }
  244. #hq-nav-bar>li.level-one:first-child {
  245. border-top: none;
  246. }
  247. #hq-nav-bar>li.level-one:hover {
  248. background: rgba(255,255,255,1);
  249. background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(233,238,242,1) 100%);
  250. background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(255,255,255,1)), color-stop(47%, rgba(246,246,246,1)), color-stop(100%, rgba(233,238,242,1)));
  251. background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(233,238,242,1) 100%);
  252. background: -o-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(233,238,242,1) 100%);
  253. background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(233,238,242,1) 100%);
  254. background: linear-gradient(to bottom, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(233,238,242,1) 100%);
  255. filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#e9eef2', GradientType=0 );
  256. }
  257. #hq-nav-bar>li.selected {
  258. background: #3f8eb9;
  259. -webkit-box-shadow: inset 1px 1px 10px 1px rgba(0,0,0,0.45);
  260. -moz-box-shadow: inset 1px 1px 10px 1px rgba(0,0,0,0.45);
  261. box-shadow: inset 1px 1px 10px 1px rgba(0,0,0,0.45);
  262. }
  263. #hq-nav-bar>li>i {
  264. color: #19A97B;
  265. margin: 25%;
  266. }
  267. .level-one {
  268. position: relative;
  269. }
  270. .level-two {
  271. display: none;
  272. position: absolute;
  273. height: 50px;
  274. width: 100px;
  275. background: #19A97B;
  276. border-radius: 4px;
  277. font-family: 'Open Sans', sans-serif;
  278. font-size: 0.65em;
  279. text-align: center;
  280. }
  281.  
  282. .level-two:after {
  283. content: '';
  284. position: absolute;
  285. border-style: solid;
  286. border-width: 9px 9px 9px 0;
  287. border-color: transparent #19A97B;
  288. display: block;
  289. width: 0;
  290. z-index: 1;
  291. left: -9px;
  292. top: 15px;
  293. }
  294.  
  295. .level-two li {
  296. margin: 15px;
  297. }
  298.  
  299. .level-one:hover > .level-two {
  300. display: block;
  301. }
  302.  
  303. .level-two {
  304. left: 130%;
  305. top: 0;
  306. }
  307. `);
  308. });

QingJ © 2025

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