精简csdn,知乎自动点击跳转

按下按钮一键隐藏csdn搜索框以及一些没有用的东西,帮您沉浸式学习当前页面内容,最重要的是粉色!

  1. // ==UserScript==
  2. // @name 精简csdn,知乎自动点击跳转
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.42
  5. // @description 按下按钮一键隐藏csdn搜索框以及一些没有用的东西,帮您沉浸式学习当前页面内容,最重要的是粉色!
  6. // @author Onion
  7. // @include *://blog.csdn.net/*/article/details/*
  8. // @include *.blog.csdn.net/article/details/*
  9. // @include *//link.zhihu.com/*
  10. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  11. // @grant none
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17. var button_1 = document.createElement("button"); //创建一个按钮
  18. button_1.textContent = "隐藏"; //按钮内容
  19. button_1.style.width = "80px"; //按钮宽度
  20. button_1.style.height = "28px"; //按钮高度
  21. button_1.style.align = "center"; //居中
  22. button_1.style.color = "#white"; //按钮文字颜色
  23. button_1.style.background = "#FFDDEE"; //按钮底色
  24. button_1.addEventListener("click", clickButton_1)
  25.  
  26. var button_2 = document.createElement("button"); //创建第二个按钮
  27. button_2.textContent = "显现"; //按钮内容
  28. button_2.style.width = "80px"; //按钮宽度
  29. button_2.style.height = "28px"; //按钮高度
  30. button_2.style.align = "center"; //居中
  31. button_2.style.color = "#white"; //按钮文字颜色
  32. button_2.style.background = "#FFDDEE"; //按钮底色
  33. button_2.addEventListener("click", clickButton_2)
  34.  
  35. function clickButton_1()
  36. {
  37. setTimeout(function() {
  38. //上方
  39. document.getElementById('toolbar-search-input').style.visibility = 'hidden';
  40. document.getElementById('toolbar-search-button').style.visibility = 'hidden';
  41. document.getElementById('csdn-toolbar').style.visibility = 'hidden';
  42. //左侧
  43. document.getElementById('asideNewComments').style.display = 'none';
  44. document.getElementById('asideHotArticle').style.display = 'none';
  45. document.getElementById('asideArchive').style.display = 'none';
  46. document.getElementById('asideNewNps').style.display = 'none'
  47. //下方
  48. document.getElementById('csdn-copyright-footer').style.visibility = 'hidden';
  49.  
  50.  
  51. // document.getElementById('asideProfile').style.visibility = 'hidden';
  52. }, 100);// 100ms后执行
  53.  
  54. }
  55. function clickButton_2()
  56. {
  57. setTimeout(function() {
  58. document.getElementById('toolbar-search-input').style.visibility = 'visible';
  59. document.getElementById('toolbar-search-button').style.visibility = 'visible';
  60. document.getElementById('csdn-toolbar').style.visibility = 'visible';
  61. //
  62. document.getElementById('asideNewComments').style.display = 'inline';
  63. document.getElementById('asideHotArticle').style.display = 'inline';
  64. document.getElementById('asideArchive').style.display = 'inline';
  65. document.getElementById('asideNewNps').style.display = 'inline'
  66. //
  67. document.getElementById('csdn-copyright-footer').style.visibility = 'visible';
  68.  
  69. }, 100);// 100ms后执行
  70.  
  71. }
  72. //按钮代码之一
  73. var toolboxclass = document.getElementsByClassName('toolbox-list')[0];
  74. toolboxclass.appendChild(button_1);
  75. toolboxclass.appendChild(button_2);//添加到子列
  76. //
  77. //粉色!!!!
  78. //其他脚本创建的ID粉色
  79. /*
  80. setTimeout(function() {
  81. document.getElementById('recommendSwitch').style.backgroundColor='pink';
  82. }, 100);
  83.  
  84. var temp1 = document.getElementsByClassName("left-toolbox");
  85. for (var i = 0; i < temp1.length; i++) {
  86. temp1[i].style.backgroundColor = "#FFDDEE";
  87. }
  88.  
  89. var temp2 = document.getElementsByClassName("blog-content-box");
  90. for (var k = 0; k < temp2.length; k++) {
  91. temp2[k].style.backgroundColor = "#FFDDEE";
  92. }
  93. //
  94. var temp3 = document.getElementsByClassName("blog_container_aside");
  95.  
  96. for (var j = 0; j < temp3.length; j++) {
  97. temp3[j].style.backgroundColor = "#FFDDEE";
  98. }
  99.  
  100. var temp4 = document.getElementsByClassName("article-header-box");
  101.  
  102. for (var m = 0; m< temp4.length; m++) {
  103. temp4[m].style.backgroundColor = "#FFDDEE";
  104. }
  105. //
  106. var temp5 = document.getElementsByClassName("prettyprint");
  107.  
  108. for (var n= 0; n < temp5.length; n++) {
  109. temp5[n].style.backgroundColor = "#FFDDEE";
  110. }
  111. var temp6 = document.getElementsByClassName("prism language-javascript has-numbering");
  112.  
  113. for (var o= 0; o < temp6.length; n++) {
  114. temp6[o].style.backgroundColor = "#FFDDEE";
  115. }7
  116.  
  117. var temp7 = document.getElementsByClassName("blog-content-box");
  118.  
  119. for (var p= 0; p< temp7.length; p++) {
  120. temp7[p].style.backgroundColor = "#FFDDEE";
  121. }
  122.  
  123. //知乎自动跳转
  124. document.querySelector('[class = "button"]').click();
  125. */
  126. // var arraytemp=["temp1","temp2","temp3","temp4","temp5"];
  127. // console.log(arraytemp[0]);
  128. // 循环代码实现
  129. var array=["toolbox-list","blog-content-box","blog_container_aside","article-header-box","prettyprint","prism language-javascript has-numbering","blog-content-box","left-toolbox","more-toolbox-new"];
  130. for (var v=0;v<array.length-1;v++){
  131. var tempx= document.getElementsByClassName(array[v]);
  132. for(var i=0; i< tempx.length;i++){
  133. tempx[i].style.backgroundColor="#FFDDEE";
  134. }
  135. }
  136. console.log(array.length);
  137.  
  138.  
  139. //console.log(array[1]);
  140. // console.log(arraytemp[1]);
  141.  
  142.  
  143.  
  144. //想要通过双重循环来做到的,失败了,不知道为甚莫qaq
  145. //3.29更新解决了这个问题,大幅精简了代码
  146.  
  147. /* var divsToHide = document.getElementsByClassName("blog_container_aside");
  148. for(var k = 0; k < divsToHide.length; k++){
  149. divsToHide[k].style.visibility = "hidden";
  150. }
  151. document.querySelectorAll('.blog_container_aside').forEach(function(el) {
  152. el.style.display = 'none';
  153. });真的看不懂了,不动它能隐藏,稍微移动一下就回去了*/
  154.  
  155. })();
  156. // document.getElementById('nav-searchform').style.visibility='hidden';

QingJ © 2025

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