Pure_CSDN

净化CSDN

  1. // ==UserScript==
  2. // @name Pure_CSDN
  3. // @namespace https://blog.csdn.net/*
  4. // @match https://blog.csdn.net/*
  5. // @grant none
  6. // @version 0.6.5
  7. // @author 13号寄信人
  8. // @description 净化CSDN
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. appendStyle(buildCss())
  16.  
  17. function buildCss() {
  18. if (browserDetection() !== "PC") {
  19. //------------------------移动端------------------------
  20. return `
  21. .wap-shadowbox , .readall_box .open_app_channelCode .btn_open_app_prompt_div {
  22. display: none !important;
  23. }
  24. .article_content{
  25. height:auto !important;
  26. }
  27. #main {
  28. padding-top: 0 !important;
  29. margin-top: 0 !important;
  30. }
  31. `
  32. } else {
  33. //------------------------桌面端------------------------
  34. return `
  35. .blog_container_aside , #rightAside , .csdn-side-toolbar , .csdn-toolbar-creative-mp-bg , .toolbar-advert {
  36. display: none !important;
  37. }
  38. #mainBox {
  39. display: flex !important;
  40. justify-content: center !important;
  41. }
  42. .container {
  43. margin-right: 0 !important;
  44. }
  45. `
  46. }
  47. }
  48.  
  49. function appendStyle(css) {
  50. let styleNode = document.createElement("style");
  51. styleNode.appendChild(document.createTextNode(css));
  52. (document.querySelector("head") || document.documentElement).appendChild(styleNode);
  53. }
  54.  
  55. function browserDetection() {
  56. const userAgent = window.navigator.userAgent.toLowerCase();
  57. let browser = null;
  58. if (userAgent.match(/ipad/i)) {
  59. browser = 'ipad';
  60. } else if (userAgent.match(/iphone os/i)) {
  61. browser = 'iphone';
  62. } else if (userAgent.match(/midp/i)) {
  63. browser = 'midp'
  64. } else if (userAgent.match(/rv:1.2.3.4/i)) {
  65. browser = 'rv:1.2.3.4';
  66. } else if (userAgent.match(/ucweb/i)) {
  67. browser = 'ucweb';
  68. } else if (userAgent.match(/android/i)) {
  69. browser = 'android';
  70. } else if (userAgent.match(/windows ce/i)) {
  71. browser = 'windowsCe';
  72. } else if (userAgent.match(/windows mobile/i)) {
  73. browser = 'windowsMobile';
  74. } else {
  75. browser = 'PC'
  76. }
  77. return browser;
  78. }
  79. })();