Pure_CSDN

净化CSDN

As of 2023-04-18. See the latest version.

  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
  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. } else {
  22. //------------------------桌面端------------------------
  23. return `
  24. .blog_container_aside {
  25. display: none !important;
  26. }
  27. #rightAside {
  28. display: none !important;
  29. }
  30. .csdn-side-toolbar {
  31. display: none !important;
  32. }
  33. #mainBox {
  34. display: flex !important;
  35. justfy-content: center !important;
  36. }
  37. `
  38. }
  39. }
  40.  
  41. function appendStyle(css) {
  42. let styleNode = document.createElement("style");
  43. styleNode.appendChild(document.createTextNode(css));
  44. (document.querySelector("head") || document.documentElement).appendChild(styleNode);
  45. }
  46.  
  47. function browserDetection() {
  48. const userAgent = window.navigator.userAgent.toLowerCase();
  49. let browser = null;
  50. if (userAgent.match(/ipad/i)) {
  51. browser = 'ipad';
  52. } else if (userAgent.match(/iphone os/i)) {
  53. browser = 'iphone';
  54. } else if (userAgent.match(/midp/i)) {
  55. browser = 'midp'
  56. } else if (userAgent.match(/rv:1.2.3.4/i)) {
  57. browser = 'rv:1.2.3.4';
  58. } else if (userAgent.match(/ucweb/i)) {
  59. browser = 'ucweb';
  60. } else if (userAgent.match(/android/i)) {
  61. browser = 'android';
  62. } else if (userAgent.match(/windows ce/i)) {
  63. browser = 'windowsCe';
  64. } else if (userAgent.match(/windows mobile/i)) {
  65. browser = 'windowsMobile';
  66. } else {
  67. browser = 'PC'
  68. }
  69. return browser;
  70. }
  71. })();