CSDN美化

CSDN去广告及主题色改变

当前为 2023-02-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name CSDN美化
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.5
  5. // @description CSDN去广告及主题色改变
  6. // @author 乃木流架
  7. // @match *://*.csdn.net/*
  8. // @match https://www.csdn.net/*
  9. // @icon https://gitee.com/chengechenge/drawing-bed/raw/master/color_book.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. const removeItems = {
  33. // 作者文章信息: ".data-info.d-flex.item-tiling",
  34. 勋章墙: ".aside-box-footer",
  35. 搜博主文章: "#asideSearchArticle",
  36. 热门文章: "#asideHotArticle",
  37. 分类专栏: "#asideCategory",
  38. 最新评论: "#asideNewComments",
  39. 您愿意向朋友推荐博客详情页吗: "#asideNewNps",
  40. 您愿意向朋友推荐CSDN个人主页吗: ".user-spm-list",
  41. 您愿意向朋友推荐CSDN首页吗: ".so-questionnaire",
  42. 你推荐CSDN的博客创作和收益体验么: "#nps-box",
  43. 最新文章: "#asideArchive",
  44. 广告: "#footerRightAds",
  45. 文库首页广告: ".el-carousel.el-carousel--horizontal",
  46. 相关推荐对你有帮助么: "#recommendNps",
  47. 谷歌广告: ".box-shadow.mb8",
  48. 登录注册流程满意度: ".satisfied-component",
  49. 开通会员全站VIP资源免费下更有千元大奖等你拿: ".profile-vip-info.no-vip",
  50. 下载CSDNapp签到领现金: ".general-info-sign",
  51. 首次完成学生认证当日购VIP可享7折后续8折: ".edu-infor-cert",
  52. 首次完成工作认证当日购VIP可享8折后续9折: ".job-infor-cert",
  53. };
  54. console.log(removeItems);
  55.  
  56. function itemsRemove(removeItems) {
  57. for (var i in removeItems) {
  58. if ($(removeItems[i]).length != 0) {
  59. console.log(i + " removing......");
  60. $(removeItems[i]).remove();
  61. }
  62. }
  63. }
  64.  
  65. function svgInit(color) {
  66. // 命名空间
  67. var SVG_NS = "http://www.w3.org/2000/svg";
  68.  
  69. // 1、创建svg容器
  70. var svg = document.createElementNS(SVG_NS, "svg");
  71.  
  72. // 2、创建svg中的 tag, 如rect
  73. var tag1 = document.createElementNS(SVG_NS, "path");
  74. var tag2 = document.createElementNS(SVG_NS, "path");
  75.  
  76. // 3、设置tag的属性
  77. tag1.setAttribute(
  78. "d",
  79. "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"
  80. );
  81. tag1.setAttribute("p-id", "1982");
  82. tag1.setAttribute("fill", color);
  83.  
  84. tag2.setAttribute(
  85. "d",
  86. "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"
  87. );
  88. tag2.setAttribute("p-id", "1983");
  89. tag2.setAttribute("fill", color);
  90.  
  91. svg.setAttribute("width", "100");
  92. svg.setAttribute("height", "100");
  93. svg.setAttribute("p-id", "1981");
  94. svg.setAttribute("viewBox", "0 0 1100 1100");
  95. svg.setAttribute("t", "1675610091655");
  96. // svg.setAttribute("style", "border: 1px solid red");
  97. svg.setAttribute("transform", "translate(-10,-20)");
  98.  
  99. // 4、将tag塞进svg中
  100. svg.appendChild(tag1);
  101. svg.appendChild(tag2);
  102.  
  103. // console.log(svg);
  104. return svg;
  105. }
  106.  
  107. function svgAdd(svg) {
  108. console.log("svgAdd......");
  109.  
  110. var imgUp = document.getElementsByClassName(
  111. "toolbar-logo toolbar-subMenu-box csdn-toolbar-fl"
  112. )[0].firstChild;
  113. var img = imgUp.firstChild;
  114. var div = document.createElement("div");
  115.  
  116. // console.log(imgUp);
  117. // console.log(img);
  118. img.remove();
  119. // console.log(imgUp);
  120. // 5、将svg塞进指定容器
  121. imgUp.appendChild(div);
  122. div.appendChild(svg);
  123. // console.log(div);
  124. }
  125.  
  126. function themeColor(color) {
  127. console.log("themeColor......");
  128.  
  129. //搜索按钮
  130. var searchButton = $("#toolbar-search-button")[0];
  131. if (searchButton != null) {
  132. searchButton.style.background = color;
  133. // console.log(searchButton);
  134. }
  135.  
  136. //发布按钮
  137. var writeNew1 = document.querySelectorAll(
  138. "#csdn-toolbar .toolbar-inside.exp1 .toolbar-btn-write.toolbar-btn-write-new>a"
  139. );
  140. var writeNew2 = document.querySelectorAll(
  141. "#csdn-toolbar .toolbar-btns .toolbar-btn-write > a"
  142. );
  143. var writeNew = "";
  144.  
  145. if (writeNew1.length == 1) {
  146. writeNew = writeNew1;
  147. } else if (writeNew2.length == 1) {
  148. writeNew = writeNew2;
  149. }
  150. if (writeNew != null && writeNew == writeNew1) {
  151. console.log(writeNew);
  152. writeNew[0].style.background = color;
  153. writeNew[0].style.backgroundImage =
  154. "url(https://g.csdnimg.cn/common/csdn-toolbar/images/icon-write.png)";
  155. writeNew[0].style.backgroundRepeat = "no-repeat";
  156. writeNew[0].style.backgroundPosition = "16px center";
  157. writeNew[0].style.backgroundSize = "16px";
  158. } else if (writeNew == writeNew2) {
  159. console.log(writeNew);
  160. writeNew[0].style.background = color;
  161. }
  162.  
  163. //创作中心发布按钮
  164. var cre = document.querySelector(".createBtn");
  165. if (cre !== null) {
  166. cre.style.background = color;
  167. }
  168.  
  169. //评论按钮
  170. var comment = document.querySelector(
  171. ".comment-box.comment-box-new2.login-comment-box-new .has-comment .has-comment-tit a.has-comment-bt-right"
  172. );
  173. // console.log(comment);
  174. if (comment !== null) {
  175. comment.style.background = color;
  176. }
  177.  
  178. // //放弃
  179. // var titleActive = window.getComputedStyle(
  180. // document.querySelector("#csdn-toolbar .toolbar-menus li"),
  181. // ":after"
  182. // );
  183. // console.log(titleActive);
  184. // titleActive.setProperty("background-color", "#1296db");
  185.  
  186. // var listActive = document.querySelector(
  187. // ".groupfile .pos-box .scroll-box .toc-box >ol li.active >a"
  188. // );
  189. // console.log(listActive);
  190. // listActive.style.color = color;
  191. }
  192.  
  193. function msgColor(color) {
  194. console.log("msgColor......");
  195.  
  196. var msgCount = document.querySelector(
  197. "#csdn-toolbar .toolbar-btns .toolbar-btn-msg #toolbar-remind i"
  198. );
  199. // console.log(msgCount);
  200.  
  201. //消息悬浮框红点
  202. var msgDots = document.querySelectorAll(
  203. "#csdn-toolbar .toolbar-btns .toolbar-btn-msg .toolbar-subMenu>a i"
  204. );
  205. // console.log(msgDots);
  206.  
  207. if (msgCount && msgDots) {
  208. msgCount.style.background = color;
  209. for (let i = 0; i < msgDots.length; i++) {
  210. msgDots[i].style.background = color;
  211. }
  212. }
  213. }
  214.  
  215. function sideHandle() {
  216. console.log("sideHandle......");
  217.  
  218. var sideItemsFather = document.querySelector(".csdn-side-toolbar");
  219. if (sideItemsFather !== null) {
  220. let sideItems = sideItemsFather.children;
  221. // console.log(sideItems);
  222. for (let i = sideItems.length - 2; i >= 0; i--) {
  223. if (
  224. sideItems[i].getAttribute("data-type") != "show" ||
  225. sideItems[i].getAttribute("data-type") != "hide"
  226. ) {
  227. // console.log(sideItems[i]);
  228. sideItems[i].remove();
  229. } else {
  230. sideItems[i].setAttribute("style", "display: none");
  231. // console.log(sideItems[i]);
  232. }
  233. }
  234. }
  235. console.log(sideItemsFather);
  236. }
  237.  
  238. function colorpickerInit() {
  239. console.log("colorpickerInit......");
  240.  
  241. var co = document.createElement("div");
  242. co.setAttribute("id", "app");
  243. co.innerHTML = '<el-color-picker v-model="color"></el-color-picker>';
  244.  
  245. return co;
  246. }
  247.  
  248. function colorpickerAdd(colorpicker) {
  249. console.log("colorpickerAdd......");
  250.  
  251. var sideItemsFather = document.querySelector(".csdn-side-toolbar");
  252. if (sideItemsFather !== null) {
  253. // sideItems = sideItemsFather.children;
  254. console.log(sideItemsFather);
  255. // var lastChild = sideItemsFather.lastElementChild;
  256. let _colorpicker = sideItemsFather.insertBefore(
  257. colorpicker,
  258. sideItemsFather.lastElementChild
  259. );
  260. }
  261.  
  262. console.log(colorpicker);
  263. }
  264.  
  265. // function colorpickerPol() {
  266. // console.log("colorpickerPol......");
  267.  
  268. // let trigger = document.getElementsByClassName(
  269. // "el-color-picker__trigger"
  270. // )[0];
  271. // let col = document.getElementsByClassName("el-color-picker__color")[0];
  272. // let col_inner = document.getElementsByClassName(
  273. // "el-color-picker__color-inner"
  274. // )[0];
  275. // console.log(trigger.style.padding);
  276. // if (trigger !== null && col !== null && col_inner !== null) {
  277. // trigger.style.padding = "";
  278. // trigger.style.border = "";
  279.  
  280. // col.style.border = "";
  281.  
  282. // col_inner.style.borderRadius = "50%";
  283. // }
  284. // }
  285.  
  286. //消息和右下角工具栏
  287.  
  288. function resourceInject() {
  289. let script = document.createElement("script");
  290. script.setAttribute("type", "text/javascript");
  291. script.src = "https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js";
  292. // script.src = "https://unpkg.com/vue@2/dist/vue.js";
  293. document.documentElement.appendChild(script);
  294.  
  295. let link = document.createElement("link");
  296. link.setAttribute("rel", "stylesheet");
  297. // link.href = "https://unpkg.com/element-ui/lib/theme-chalk/index.css";
  298. link.href =
  299. "https://fastly.jsdelivr.net/gh/TojoSeita/vue-study.github.io@main/index.css";
  300. document.documentElement.appendChild(link);
  301.  
  302. let elscript = document.createElement("script");
  303. elscript.setAttribute("type", "text/javascript");
  304. elscript.src = "https://unpkg.com/element-ui/lib/index.js";
  305. document.documentElement.appendChild(elscript);
  306. }
  307.  
  308. var handle = setInterval(() => {
  309. //函数调用
  310. // 1、元素删除
  311. itemsRemove(removeItems);
  312. // 2、图标更改
  313. // if (GM_getValue("color") == null) {
  314. // svgAdd(svgInit(GM_getValue("colorDefault")));
  315. // } else {
  316. // svgAdd(svgInit(GM_getValue("color")));
  317. // }
  318.  
  319. // // 3、主题颜色更改
  320. // themeColor(color);
  321. // // 4、消息红点更改
  322. // msgHandle();
  323. // 5、右下角工具栏删除
  324. // sideHandle();
  325. // colorPicker();
  326. }, 1000);
  327.  
  328. resourceInject();
  329.  
  330. window.onload = () => {
  331. //函数调用
  332. // 1、元素删除
  333. // itemsRemove(removeItems);
  334.  
  335. // 2、右下角工具栏删除
  336. sideHandle();
  337.  
  338. clearInterval(handle);
  339. console.log("clearInterval......");
  340.  
  341. // 3、颜色选择器生成
  342. colorpickerAdd(colorpickerInit());
  343.  
  344. new Vue({
  345. // el: "#app",
  346. el:
  347. document.getElementsByClassName("csdn-side-toolbar ")[0] == undefined
  348. ? {}
  349. : document.getElementsByClassName("csdn-side-toolbar ")[0]
  350. .firstElementChild,
  351. data: function () {
  352. return {
  353. color:
  354. // localStorage.getItem("color") == null
  355. // ? localStorage.getItem("colorDefault")
  356. // : localStorage.getItem("color"),
  357. GM_getValue("color") == null
  358. ? GM_getValue("colorDefault")
  359. : GM_getValue("color"),
  360. };
  361. },
  362. methods: {
  363. hello() {
  364. console.log("hello......");
  365. },
  366. },
  367. watch: {
  368. color: {
  369. handler(newVal, oldVal) {
  370. console.log("newVal: ", newVal);
  371. console.log("oldVal: ", oldVal);
  372.  
  373. //本地存储所选颜色
  374. GM_setValue("color", newVal);
  375.  
  376. console.log("colorDefault: " + GM_getValue("colorDefault"));
  377. console.log("color: " + GM_getValue("color"));
  378. // 4、图标颜色更改
  379. svgAdd(svgInit(newVal));
  380. // 5、主题颜色更改
  381. themeColor(newVal);
  382. // 6、消息红点更改
  383. msgColor(newVal);
  384. },
  385. immediate: true,
  386. },
  387. },
  388. });
  389.  
  390. console.log(GM_listValues());
  391.  
  392. // colorpickerPol();
  393. };
  394.  
  395. // Your code here...
  396. })();