CSDN美化

CSDN去广告及主题色改变

  1. // ==UserScript==
  2. // @name CSDN美化
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.8
  5. // @description CSDN去广告及主题色改变
  6. // @author 乃木流架
  7. // @match *://*.csdn.net/*
  8. // @match https://www.csdn.net/*
  9. // @icon https://i.jpg.dog/4419a191c8805d1406bbba51431eb188.png
  10. // @grant unsafeWindow
  11. // @grant GM_setValue
  12. // @grant GM_getValue
  13. // @grant GM_listValues
  14. // @run-at document-start
  15. // @require https://unpkg.com/sweetalert2/dist/sweetalert2.min.js
  16. // @require https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js
  17. // @license GPL-3.0 License
  18. // ==/UserScript==
  19.  
  20. (function () {
  21. ("use strict");
  22.  
  23. //设置默认颜色 https://nipponcolors.com/
  24. // 桃 "#F596AA"
  25. // 桜 "#FEDFE1"
  26. // 灰桜 "#D7C4BB"
  27. // 露草 "#2EA9DF"
  28. // 若竹 "#5DAC81"
  29. // 桔梗 "#6A4C9C"
  30. GM_setValue("colorDefault", "#F596AA");
  31.  
  32. function log(msg) {
  33. let title = "CSDN美化";
  34. let titleCss =
  35. "color:#FFF;font-size: 8px;font-weight:800;padding:4px 5px 2px 5px;border-radius:3px;background: rgb(237,85,100);background: linear-gradient(90deg, rgba(237,85,100,1) 0%, rgba(252,110,81,1) 14%, rgba(255,206,84,1) 28%, rgba(160,212,104,1) 42%, rgba(72,207,173,1) 56%, rgba(79,194,233,1) 70%, rgba(93,156,236,1) 84%, rgba(172,146,235,1) 100%);";
  36. let m = msg;
  37. let mCss = "font-size: 8px;";
  38.  
  39. if (typeof m == "object") {
  40. console.log("%c%s", titleCss, title);
  41. console.log(m);
  42. return;
  43. }
  44.  
  45. console.log("%c%s%c %s", titleCss, title, mCss, m);
  46. }
  47.  
  48. const removeItems = {
  49. // 作者文章信息: ".data-info.d-flex.item-tiling",
  50. 勋章墙: ".aside-box-footer",
  51. 搜博主文章: "#asideSearchArticle",
  52. 热门文章: "#asideHotArticle",
  53. 分类专栏: "#asideCategory",
  54. 最新评论: "#asideNewComments",
  55. 您愿意向朋友推荐博客详情页吗: "#asideNewNps",
  56. 您愿意向朋友推荐CSDN个人主页吗: ".user-spm-list",
  57. 您愿意向朋友推荐CSDN首页吗: ".so-questionnaire",
  58. 你推荐CSDN的博客创作和收益体验么: "#nps-box",
  59. 最新文章: "#asideArchive",
  60. 广告: "#footerRightAds",
  61. 文库首页广告: ".el-carousel.el-carousel--horizontal",
  62. 相关推荐对你有帮助么: "#recommendNps",
  63. 谷歌广告: ".box-shadow.mb8",
  64. 登录注册流程满意度: ".satisfied-component",
  65. 开通会员全站VIP资源免费下更有千元大奖等你拿: ".profile-vip-info.no-vip",
  66. 下载CSDNapp签到领现金: ".general-info-sign",
  67. 首次完成学生认证当日购VIP可享7折后续8折: ".edu-infor-cert",
  68. 首次完成工作认证当日购VIP可享8折后续9折: ".job-infor-cert",
  69. };
  70.  
  71. log(removeItems);
  72.  
  73. function itemsRemove(removeItems) {
  74. for (var i in removeItems) {
  75. if ($(removeItems[i]).length != 0) {
  76. log(i + " removing......");
  77. $(removeItems[i]).remove();
  78. }
  79. }
  80. }
  81.  
  82. function svgInit(color) {
  83. // 命名空间
  84. var SVG_NS = "http://www.w3.org/2000/svg";
  85.  
  86. // 1、创建svg容器
  87. var svg = document.createElementNS(SVG_NS, "svg");
  88.  
  89. // 2、创建svg中的 tag, 如rect
  90. var tag1 = document.createElementNS(SVG_NS, "path");
  91. var tag2 = document.createElementNS(SVG_NS, "path");
  92.  
  93. // 3、设置tag的属性
  94. tag1.setAttribute(
  95. "d",
  96. "M672.299893 374.246613c-30.004361-6.185886-61.073984-9.064446-91.749634-9.685593-41.186028-0.835018-41.774429 0.635473-46.343491 40.450271-5.634324 49.097208-10.223852 98.314143-15.640212 151.144372 31.054273 0.64673 60.628846 2.199085 90.162486 1.626034 32.461319-0.629333 63.944358-6.411013 90.443895-27.424606 29.843702-23.666002 39.58967-55.474452 34.120099-91.764983C728.039381 403.724994 705.951317 381.184629 672.299893 374.246613zM657.900951 500.909407c-23.899316 18.074657-51.306526 20.665669-82.688257 16.613376 3.77907-38.039361 7.468089-75.166957 11.500938-115.768677 18.166755 1.276063 34.453696 1.294482 50.341548 3.818979 20.170388 3.204995 36.021401 13.485129 40.776705 34.985816C683.099866 464.37533 678.124552 485.615073 657.900951 500.909407zM503.672334 369.780905c-1.798972 13.027711-3.473101 25.15082-5.205559 37.702694-25.127284-2.170432-49.036833-5.149277-73.019037-5.934153-12.665461-0.414439-25.856901 1.651616-38.011732 5.276167-5.569856 1.660826-9.213849 9.779737-13.731746 14.969946 4.811586 4.14132 8.978489 10.243295 14.548344 12.07092 20.290115 6.65763 41.37534 10.943236 61.541635 17.912975 21.155832 7.312546 42.117237 17.118889 43.12417 43.801599 1.025353 27.151383-17.099447 42.173518-39.515992 51.339272-49.971112 20.434401-101.250008 18.301831-152.551418 5.27412-2.898003-0.735757-6.615675-6.172583-6.522554-9.320273 0.313132-10.570753 2.179642-21.095457 3.244904-29.927613 30.601972 2.39556 60.002582 5.354961 89.476871 6.611581 9.122775 0.388856 19.11229-2.468215 27.425629-6.486738 5.1503-2.489704 10.989285-10.093892 10.780531-15.165398-0.184195-4.474918-7.630794-10.624988-13.091156-12.520151-13.767562-4.780887-28.474518-6.819313-42.334177-11.387351-13.833053-4.558829-27.958772-9.378601-40.431851-16.687054-29.591969-17.339924-31.312146-47.346331-4.841262-69.316715 20.354584-16.893762 44.992727-22.240537 70.433142-25.527396C426.702312 358.37104 479.267505 361.432773 503.672334 369.780905zM959.473381 445.082938c-2.599198 35.797297-7.000438 71.464635-10.664897 107.833961-19.322068 0-37.140898 0-57.091276 0 3.668553-34.127262 6.729262-67.476811 10.968819-100.67491 4.237511-33.18275-7.367805-47.762817-40.654932-48.962132-40.755216-1.468444-40.883129-1.482771-45.26595 38.807864-3.950985 36.326347-7.580652 72.687486-11.507078 110.530372-19.435655 0-37.172621 0-55.32812 0 5.699816-58.20361 11.107989-115.27749 17.277502-172.269505 0.410346-3.78828 6.15007-9.250688 10.17985-10.045797 38.780235-7.6574 77.796854-12.57848 117.373221-6.016017C941.27081 371.999432 962.885084 398.084531 959.473381 445.082938zM251.989151 359.040283c11.636015 0.905626 23.165606 3.169179 35.938514 4.976338-1.662873 15.230889-3.163039 28.963659-4.333702 39.687908-30.569226 0-58.112536-1.639337-85.379553 0.411369-34.80469 2.616594-56.879452 20.388353-63.36926 46.690392-8.036024 32.567743 5.16258 57.6807 38.144762 63.129806 25.119097 4.149507 51.359738 1.601474 77.102029 1.802042 4.854565 0.037862 9.718339-1.010003 13.933337-1.483794 1.093914 1.38044 1.75804 1.827625 1.74883 2.260483-0.845251 41.947368-0.855484 43.796482-42.837644 43.626613-31.178093-0.125867-63.113433-2.62171-93.28971-9.93221-33.339316-8.077979-58.892295-29.67588-64.336284-66.284659-5.77554-38.832424 10.547217-69.608358 41.553395-91.998297C150.319587 360.548636 200.264093 355.014596 251.989151 359.040283z"
  97. );
  98. tag1.setAttribute("p-id", "1982");
  99. tag1.setAttribute("fill", color);
  100.  
  101. tag2.setAttribute(
  102. "d",
  103. "M137.883347 595.666538l-1.199315 1.499144c6.715959 8.794293 15.628956 15.409968 26.742061 19.847024-1.239224 1.759063-2.298346 3.357468-3.177366 4.797259-10.553357-5.196349-19.407002-12.172227-26.561959-20.925588-6.116301 7.91425-15.150048 15.150048-27.101241 21.705348-0.799202-1.358951-1.798972-2.858094-2.998287-4.497431 12.351306-6.196119 21.684882-13.670348 28.000728-22.424732L137.883347 595.667561zM106.34505 646.871757l24.762987 0 0-10.432607-19.426445 0 0-4.376681 19.426445 0 0-9.233292-17.207917 0 0-4.376681 39.45357 0 0 4.376681-17.268292 0 0 9.233292 19.48682 0 0 4.376681-19.48682 0 0 10.432607 24.703635 0 0 4.437056-54.44296 0L106.346073 646.871757zM195.804525 642.434701c2.698458-0.279363 5.536087-0.60989 8.513908-0.989537l0-18.138102-7.374968 0 0-4.317329 7.374968 0 0-14.090926-8.154727 0 0-4.317329 20.506033 0 0 4.317329-7.974625 0 0 14.090926 6.955412 0 0 4.317329-6.955412 0 0 17.568121c2.39863-0.339738 4.876054-0.699941 7.435343-1.079588-0.160659 1.599428-0.25992 3.137457-0.299829 4.617158-7.475252 0.959861-13.950733 1.858324-19.426445 2.698458L195.804525 642.434701zM216.430284 638.536928c5.216815-3.177366 10.673084-6.715959 16.368806-10.612709L232.79909 610.476849l-15.349593 0 0-4.317329 15.349593 0 0-10.673084 4.556783 0 0 10.673084 17.028838 0 0 4.317329-17.028838 0 0 5.336542c0.99977 3.27765 2.168386 6.315846 3.507894 9.113565 3.457752-3.357468 6.345522-6.456039 8.664334-9.293667l3.897773 3.298116c-3.298116 3.258207-6.804986 6.5553-10.522658 9.893324 3.477194 6.016017 7.804756 10.673084 12.981662 13.970176-0.239454 0.360204-0.760317 0.979304-1.558495 1.858324-0.880043 0.918929-1.499144 1.639337-1.858324 2.158153-6.5553-4.736884-11.592013-11.552104-15.110139-20.445658l0 19.367093c0 4.756327-2.478448 7.135514-7.435343 7.135514-1.959631 0-4.057409-0.020466-6.29538-0.060375-0.239454-1.518586-0.559748-3.157923-0.959861-4.916986 2.357697 0.279363 4.497431 0.419556 6.41613 0.419556 2.477424 0 3.717671-1.218758 3.717671-3.657296l0-11.422144c-4.137227 2.87856-8.593725 6.085602-13.370519 9.623171L216.430284 638.536928zM217.749326 616.891955l3.657296-2.218528c2.598174 3.397377 5.175883 7.154957 7.735172 11.272741l-3.837398 2.638083C222.545562 623.907743 220.028229 620.009969 217.749326 616.891955zM240.593614 599.024006l2.638083-2.998287c2.837628 1.87879 5.435803 3.816932 7.794523 5.816472l-2.87856 3.298116C245.789962 602.941222 243.271606 600.902796 240.593614 599.024006zM288.621467 646.152373c1.958608-0.199545 3.917216-0.409322 5.875824-0.629333l0-22.814612-6.595208 0 0-3.597945 59.419298 0 0 3.597945-31.298843 0 0 19.996426c1.918699-0.279363 3.837398-0.569982 5.756097-0.86981-0.040932 0.719384-0.020466 1.998517 0.060375 3.837398-1.87879 0.25992-3.817955 0.530073-5.816472 0.809435l0 7.645121-4.076852 0 0-7.045463c-6.875594 0.979304-14.290471 2.088568-22.24463 3.327792L288.621467 646.152373zM296.955272 597.405135l41.491996 0 0 19.247366-4.197602 0 0-1.379417L301.152874 615.273085l0 1.379417-4.197602 0L296.955272 597.405135zM298.574143 627.504664l13.370519 0 0-4.797259L298.574143 622.707404 298.574143 627.504664zM298.574143 635.779118l13.370519 0 0-4.797259L298.574143 630.981858 298.574143 635.779118zM311.945685 643.304512l0-4.047176L298.574143 639.257336l0 5.785773C303.091016 644.502803 307.548538 643.923612 311.945685 643.304512zM334.25069 600.883353 301.152874 600.883353l0 3.837398 33.097816 0L334.25069 600.883353zM301.152874 611.79589l33.097816 0 0-3.837398L301.152874 607.958492 301.152874 611.79589zM319.020824 630.442576l0-3.477194 23.804149 0 0 3.477194c-2.038426 4.89652-4.717442 9.153474-8.035 12.770861 3.417843 2.49789 7.65433 4.397147 12.71151 5.695722-1.039679 1.518586-1.939165 2.918469-2.698458 4.197602-5.15644-1.698688-9.503445-3.997034-13.041014-6.895037-3.437286 3.078105-7.445576 5.596462-12.021801 7.55507-0.679475-1.199315-1.599428-2.457981-2.75781-3.777023 4.53734-1.738597 8.443299-3.957125 11.721973-6.655584-3.338025-3.577478-5.716188-7.874341-7.135514-12.891611L319.020824 630.442576zM338.267167 630.442576l-12.651135 0c1.258667 3.937682 3.28686 7.305383 6.085602 10.103102C334.479911 637.628232 336.667739 634.260531 338.267167 630.442576zM379.939265 649.149637c16.488533-7.335059 25.382087-18.34788 26.681686-33.037441l-25.603121 0 0-4.676509 25.812899 0c0.100284-5.376451 0.149403-10.79281 0.149403-16.249079l5.216815 0c0 5.376451-0.050142 10.79281-0.149403 16.249079l26.591635 0 0 4.676509-26.681686 0c2.837628 15.968693 12.151761 26.501584 27.941376 31.598672-2.038426 1.958608-3.558036 3.577478-4.556783 4.856611-13.011338-5.236258-21.515013-14.560624-25.51307-27.971052-3.118014 12.131295-11.841699 21.85475-26.172079 29.170366C382.857734 652.688229 381.618511 651.149177 379.939265 649.149637zM476.234425 607.77839l23.084765 0 0-13.07069 5.15644 0 0 13.07069 23.324218 0 0 27.341718-4.916986 0 0-3.237741-18.407232 0 0 22.305005-5.15644 0 0-22.305005-18.167778 0 0 3.237741-4.916986 0L476.234425 607.77839zM481.150388 627.445312l18.167778 0 0-15.229866-18.167778 0L481.150388 627.445312zM522.882861 612.215446l-18.407232 0 0 15.229866 18.407232 0L522.882861 612.215446zM565.153594 605.199659l28.780487 0c-2.018983-3.837398-3.597945-6.635117-4.736884-8.394181l4.617158-2.158153c1.119497 1.719154 2.797719 4.516874 5.036713 8.394181l-4.317329 2.158153 28.180829 0 0 4.437056-11.062963 0c-2.13871 11.411911-6.735401 20.585851-13.791098 27.52182 5.316076 3.877307 13.760398 7.355525 25.332968 10.432607-1.838881 2.078335-3.237741 3.816932-4.197602 5.216815-11.272741-3.897773-19.596314-7.974625-24.972764-12.231579-5.395894 4.197602-14.020318 8.43409-25.872251 12.71151-1.039679-1.39886-2.238994-2.958378-3.597945-4.676509 11.432377-3.437286 20.036335-7.265474 25.812899-11.482519-7.29515-7.794523-11.93175-16.95823-13.910824-27.491121l-11.302417 0L565.152571 605.199659zM606.525863 609.636714l-25.272593 0c1.798972 9.832949 6.095835 17.958 12.891611 24.373107C600.639806 627.974361 604.7668 619.850333 606.525863 609.636714zM671.851685 604.50995l-4.466732 0 0 36.305881 4.466732 0 0 5.066389-14.930037 0 0-5.066389 4.466732 0 0-36.305881-4.466732 0 0-5.066389 14.930037 0L671.851685 604.50995zM738.196719 604.780103l-13.401218 0 0 41.102117-6.02625 0 0-41.102117-13.340843 0 0-5.336542 32.767288 0L738.195695 604.780103zM771.71409 611.496062l0-4.317329 19.48682 0 0 4.437056c-1.939165 3.877307-4.237511 7.544837-6.895037 11.002588l0 30.908964-4.676509 0 0-25.482371c-2.198062 2.318812-4.577249 4.516874-7.135514 6.595208-0.360204-1.438769-0.918929-3.097548-1.679245-4.976338 6.15621-4.956895 11.252275-11.012821 15.289218-18.167778L771.71409 611.496062zM777.649266 597.105307l4.197602-2.098801c1.478677 2.358721 3.038196 5.096065 4.676509 8.214079l-4.437056 2.278903C780.527826 602.261747 779.049149 599.464027 777.649266 597.105307zM785.024234 625.946168l3.118014-2.578732c2.438539 2.717901 4.657067 5.296633 6.655584 7.735172l-3.717671 2.937912C789.161461 631.28271 787.143501 628.584252 785.024234 625.946168zM791.20091 646.991484l16.848737 0 0-29.380144-14.270005 0 0-4.676509 14.270005 0 0-17.568121 4.797259 0 0 17.568121 15.229866 0 0 4.676509-15.229866 0 0 29.380144 17.028838 0 0 4.676509-38.673811 0L791.201933 646.991484zM867.8885 599.143733l51.565423 0 0 4.676509-46.468334 0 0 41.851177 47.428196 0 0 4.556783-52.524261 0L867.889523 599.143733zM877.601722 610.416474l3.357468-3.177366c4.996804 4.116761 10.222829 8.634658 15.679098 13.550621 4.177136-4.516874 8.184403-9.43386 12.021801-14.749936l4.376681 2.937912c-4.197602 5.436826-8.454556 10.472516-12.770861 15.110139 4.976338 4.53734 10.132778 9.393951 15.46932 14.569834l-4.137227 4.197602c-4.837168-5.056156-9.813506-10.05296-14.930037-14.989389-5.776563 5.856381-11.652388 11.012821-17.628496 15.46932-0.959861-1.239224-2.238994-2.537799-3.837398-3.897773 6.275937-4.27742 12.241812-9.263991 17.897625-14.959713C888.084471 619.739816 882.918821 615.053074 877.601722 610.416474z"
  104. );
  105. tag2.setAttribute("p-id", "1983");
  106. tag2.setAttribute("fill", color);
  107.  
  108. svg.setAttribute("width", "100");
  109. svg.setAttribute("height", "100");
  110. svg.setAttribute("p-id", "1981");
  111. svg.setAttribute("viewBox", "0 0 1100 1100");
  112. svg.setAttribute("t", "1675610091655");
  113. // svg.setAttribute("style", "border: 1px solid red");
  114. svg.setAttribute("transform", "translate(-10,-20)");
  115.  
  116. // 4、将tag塞进svg中
  117. svg.appendChild(tag1);
  118. svg.appendChild(tag2);
  119.  
  120. // log(svg);
  121. return svg;
  122. }
  123.  
  124. function svgAdd(svg) {
  125. log("svgAdd......");
  126.  
  127. var imgUp = document.getElementsByClassName(
  128. "toolbar-logo toolbar-subMenu-box csdn-toolbar-fl"
  129. )[0].firstChild;
  130. var img = imgUp.firstChild;
  131. var div = document.createElement("div");
  132.  
  133. // log(imgUp);
  134. // log(img);
  135. img.remove();
  136. // log(imgUp);
  137. // 5、将svg塞进指定容器
  138. imgUp.appendChild(div);
  139. div.appendChild(svg);
  140. // log(div);
  141. }
  142.  
  143. function themeColor(color) {
  144. log("themeColor......");
  145.  
  146. //搜索按钮
  147. var searchButton = $("#toolbar-search-button")[0];
  148. if (searchButton != null) {
  149. searchButton.style.background = color;
  150. // log(searchButton);
  151. }
  152.  
  153. //发布按钮
  154. var writeNew1 = document.querySelectorAll(
  155. "#csdn-toolbar .toolbar-inside.exp1 .toolbar-btn-write.toolbar-btn-write-new>a"
  156. );
  157. var writeNew2 = document.querySelectorAll(
  158. "#csdn-toolbar .toolbar-btns .toolbar-btn-write > a"
  159. );
  160. var writeNew = "";
  161.  
  162. if (writeNew1.length == 1) {
  163. writeNew = writeNew1;
  164. } else if (writeNew2.length == 1) {
  165. writeNew = writeNew2;
  166. }
  167. if (writeNew != null && writeNew == writeNew1) {
  168. // log(writeNew);
  169. writeNew[0].style.background = color;
  170. writeNew[0].style.backgroundImage =
  171. "url(https://g.csdnimg.cn/common/csdn-toolbar/images/icon-write.png)";
  172. writeNew[0].style.backgroundRepeat = "no-repeat";
  173. writeNew[0].style.backgroundPosition = "16px center";
  174. writeNew[0].style.backgroundSize = "16px";
  175. } else if (writeNew == writeNew2) {
  176. // log(writeNew);
  177. writeNew[0].style.background = color;
  178. }
  179.  
  180. //创作中心发布按钮
  181. var cre = document.querySelector(".createBtn");
  182. if (cre !== null) {
  183. cre.style.background = color;
  184. }
  185.  
  186. //评论按钮
  187. var comment = document.querySelector(
  188. ".comment-box.comment-box-new2.login-comment-box-new .has-comment .has-comment-tit a.has-comment-bt-right"
  189. );
  190. // log(comment);
  191. if (comment !== null) {
  192. comment.style.background = color;
  193. }
  194.  
  195. // //放弃
  196. // var titleActive = window.getComputedStyle(
  197. // document.querySelector("#csdn-toolbar .toolbar-menus li"),
  198. // ":after"
  199. // );
  200. // log(titleActive);
  201. // titleActive.setProperty("background-color", "#1296db");
  202.  
  203. // var listActive = document.querySelector(
  204. // ".groupfile .pos-box .scroll-box .toc-box >ol li.active >a"
  205. // );
  206. // log(listActive);
  207. // listActive.style.color = color;
  208. }
  209.  
  210. function msgColor(color) {
  211. log("msgColor......");
  212.  
  213. var msgCount = document.querySelector(
  214. "#csdn-toolbar .toolbar-btns .toolbar-btn-msg #toolbar-remind i"
  215. );
  216. // log(msgCount);
  217.  
  218. //消息悬浮框红点
  219. var msgDots = document.querySelectorAll(
  220. "#csdn-toolbar .toolbar-btns .toolbar-btn-msg .toolbar-subMenu>a i"
  221. );
  222. // log(msgDots);
  223.  
  224. if (msgCount && msgDots) {
  225. msgCount.style.background = color;
  226. for (let i = 0; i < msgDots.length; i++) {
  227. msgDots[i].style.background = color;
  228. }
  229. }
  230. }
  231.  
  232. function sideHandle() {
  233. log("sideHandle......");
  234.  
  235. var sideItemsFather = document.querySelector(".csdn-side-toolbar");
  236. if (sideItemsFather !== null) {
  237. let sideItems = sideItemsFather.children;
  238. // log(sideItems);
  239. for (let i = sideItems.length - 2; i >= 0; i--) {
  240. if (
  241. sideItems[i].getAttribute("data-type") != "show" ||
  242. sideItems[i].getAttribute("data-type") != "hide"
  243. ) {
  244. // log(sideItems[i]);
  245. sideItems[i].remove();
  246. } else {
  247. sideItems[i].setAttribute("style", "display: none");
  248. // log(sideItems[i]);
  249. }
  250. }
  251. }
  252. // log(sideItemsFather);
  253. }
  254.  
  255. function colorpickerInit() {
  256. log("colorpickerInit......");
  257.  
  258. var co = document.createElement("div");
  259. co.setAttribute("id", "app");
  260. co.innerHTML = '<el-color-picker v-model="color"></el-color-picker>';
  261.  
  262. return co;
  263. }
  264.  
  265. function colorpickerAdd(colorpicker) {
  266. log("colorpickerAdd......");
  267.  
  268. var sideItemsFather = document.querySelector(".csdn-side-toolbar");
  269. if (sideItemsFather !== null) {
  270. // sideItems = sideItemsFather.children;
  271. // log(sideItemsFather);
  272. // var lastChild = sideItemsFather.lastElementChild;
  273. let _colorpicker = sideItemsFather.insertBefore(
  274. colorpicker,
  275. sideItemsFather.lastElementChild
  276. );
  277. }
  278.  
  279. // log(colorpicker);
  280. }
  281.  
  282. // function colorpickerPol() {
  283. // log("colorpickerPol......");
  284.  
  285. // let trigger = document.getElementsByClassName(
  286. // "el-color-picker__trigger"
  287. // )[0];
  288. // let col = document.getElementsByClassName("el-color-picker__color")[0];
  289. // let col_inner = document.getElementsByClassName(
  290. // "el-color-picker__color-inner"
  291. // )[0];
  292. // log(trigger.style.padding);
  293. // if (trigger !== null && col !== null && col_inner !== null) {
  294. // trigger.style.padding = "";
  295. // trigger.style.border = "";
  296.  
  297. // col.style.border = "";
  298.  
  299. // col_inner.style.borderRadius = "50%";
  300. // }
  301. // }
  302.  
  303. //消息和右下角工具栏
  304.  
  305. function resourceInject() {
  306. let script = document.createElement("script");
  307. script.setAttribute("type", "text/javascript");
  308. script.src = "https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js";
  309. // script.src = "https://unpkg.com/vue@2/dist/vue.js";
  310. document.documentElement.appendChild(script);
  311.  
  312. let link = document.createElement("link");
  313. link.setAttribute("rel", "stylesheet");
  314. // link.href = "https://unpkg.com/element-ui/lib/theme-chalk/index.css";
  315. link.href =
  316. "https://fastly.jsdelivr.net/gh/TojoSeita/vue-study.github.io@main/index.css";
  317. document.documentElement.appendChild(link);
  318.  
  319. let elscript = document.createElement("script");
  320. elscript.setAttribute("type", "text/javascript");
  321. elscript.src = "https://unpkg.com/element-ui/lib/index.js";
  322. document.documentElement.appendChild(elscript);
  323. }
  324.  
  325. var handle = setInterval(() => {
  326. //函数调用
  327. // 1、元素删除
  328. itemsRemove(removeItems);
  329. // 2、图标更改
  330. // if (GM_getValue("color") == null) {
  331. // svgAdd(svgInit(GM_getValue("colorDefault")));
  332. // } else {
  333. // svgAdd(svgInit(GM_getValue("color")));
  334. // }
  335.  
  336. // // 3、主题颜色更改
  337. // themeColor(color);
  338. // // 4、消息红点更改
  339. // msgHandle();
  340. // 5、右下角工具栏删除
  341. // sideHandle();
  342. // colorPicker();
  343. }, 1000);
  344.  
  345. resourceInject();
  346.  
  347. window.onload = () => {
  348. //去除关注博主即可阅读全文
  349. var article_content = document.getElementById("article_content");
  350. var follow_text = document.getElementsByClassName("follow-text")[0];
  351. var hide_article_box =
  352. document.getElementsByClassName(" hide-article-box")[0];
  353.  
  354. if (follow_text != null) {
  355. article_content.removeAttribute("style");
  356. follow_text.parentElement.parentElement.removeChild(
  357. follow_text.parentElement
  358. );
  359. hide_article_box.parentElement.removeChild(hide_article_box);
  360. log("阅读全文解锁成功!");
  361. }
  362. //函数调用
  363. // 1、元素删除
  364. // itemsRemove(removeItems);
  365.  
  366. // 2、右下角工具栏删除
  367. sideHandle();
  368.  
  369. clearInterval(handle);
  370. log("clearInterval......");
  371.  
  372. // 3、颜色选择器生成
  373. colorpickerAdd(colorpickerInit());
  374.  
  375. new Vue({
  376. // el: "#app",
  377. el:
  378. document.getElementsByClassName("csdn-side-toolbar ")[0] == undefined
  379. ? {}
  380. : document.getElementsByClassName("csdn-side-toolbar ")[0]
  381. .firstElementChild,
  382. data: function () {
  383. return {
  384. color:
  385. // localStorage.getItem("color") == null
  386. // ? localStorage.getItem("colorDefault")
  387. // : localStorage.getItem("color"),
  388. GM_getValue("color") == null
  389. ? GM_getValue("colorDefault")
  390. : GM_getValue("color"),
  391. };
  392. },
  393. methods: {
  394. hello() {
  395. log("hello......");
  396. },
  397. },
  398. watch: {
  399. color: {
  400. handler(newVal, oldVal) {
  401. log("newVal: " + newVal);
  402. log("oldVal: " + oldVal);
  403.  
  404. //本地存储所选颜色
  405. GM_setValue("color", newVal);
  406.  
  407. log("colorDefault: " + GM_getValue("colorDefault"));
  408. log("color: " + GM_getValue("color"));
  409. // 4、图标颜色更改
  410. svgAdd(svgInit(newVal));
  411. // 5、主题颜色更改
  412. themeColor(newVal);
  413. // 6、消息红点更改
  414. msgColor(newVal);
  415. },
  416. immediate: true,
  417. },
  418. },
  419. });
  420.  
  421. // log(GM_listValues());
  422.  
  423. // colorpickerPol();
  424. };
  425.  
  426. // Your code here...
  427. })();