YCKCEO

Beautify the YCKCEO.

  1. // ==UserScript==
  2. // @name YCKCEO
  3. // @name:zh-CN 源仓库
  4. // @description Beautify the YCKCEO.
  5. // @description:zh-CN 美化源仓库。
  6. // @namespace https://github.com/HaleShaw
  7. // @version 1.0.0
  8. // @author HaleShaw
  9. // @copyright 2022+, HaleShaw (https://github.com/HaleShaw)
  10. // @license AGPL-3.0-or-later
  11. // @homepage https://github.com/HaleShaw/TM-YCKCEO
  12. // @supportURL https://github.com/HaleShaw/TM-YCKCEO/issues
  13. // @contributionURL https://www.jianwudao.com/
  14. // @icon http://www.yckceo.com/favicon.ico
  15. // @match http://www.yckceo.com/*
  16. // @compatible Chrome
  17. // @grant GM_addStyle
  18. // ==/UserScript==
  19.  
  20. // ==OpenUserJS==
  21. // @author HaleShaw
  22. // @collaborator HaleShaw
  23. // ==/OpenUserJS==
  24.  
  25. (function () {
  26. 'use strict';
  27.  
  28. const menuStyle = `
  29. .layui-layer-dialog .layui-layer-content {
  30. height: 508px !important;
  31. overflow-y: hidden !important;
  32. }
  33.  
  34. .layui-layer-dialog {
  35. height: 600px !important;
  36. }
  37. .layui-footer.footer.footer-demo {
  38. display: none !important;
  39. }
  40. `;
  41.  
  42. const beautifulStyle = `
  43. .laytable-cell-1-0-1,
  44. .laytable-cell-1-0-2 {
  45. width: 810px !important;
  46. }
  47.  
  48. .layui-btn-group {
  49. font-size: inherit !important;
  50. }
  51. span.head.count {
  52. display: inline-block;
  53. width: 3rem;
  54. text-align: center;
  55. vertical-align: middle;
  56. margin-left: 5px;
  57. }
  58.  
  59. div.layui-table-box > div.layui-table-header > table > thead > tr > th:nth-child(4),
  60. div.layui-table-box > div.layui-table-body.layui-table-main > table > tbody > tr > td:nth-child(4),
  61. #comments-section {
  62. display: none !important;
  63. }
  64.  
  65. .layui-table-cell .layui-table-link {
  66. width: 400px;
  67. display: inline-block;
  68. }
  69.  
  70. div.layui-table-box > div.layui-table-body.layui-table-main > table > tbody > tr > td:nth-child(3) > div > a:nth-child(1) {
  71. width: 200px;
  72. display: inline-block;
  73. }
  74.  
  75. div.layui-body.layui-tab-content.site-demo.site-demo-body > div.layui-main ~div {
  76. display: none !important;
  77. }
  78.  
  79. body .layui-layout-admin .site-demo {
  80. bottom: 0 !important;
  81. }
  82. `;
  83. const shuYuanUrl = '/yuedu/shuyuan/index.html';
  84.  
  85. main();
  86.  
  87. function main() {
  88. GM_addStyle(menuStyle);
  89. GM_addStyle(beautifulStyle);
  90. logInfo(GM_info.script.name, GM_info.script.version);
  91.  
  92. if (location.pathname == shuYuanUrl) {
  93. setTimeout(() => {
  94. addButton();
  95. }, 2000);
  96. }
  97. }
  98.  
  99.  
  100. function beautifyShuYuan() {
  101. document.querySelectorAll('div.layui-table-box > div.layui-table-body.layui-table-main > table > tbody > tr > td:nth-child(4)');
  102. let trList = document.querySelectorAll('div.layui-table-box > div.layui-table-body.layui-table-main > table > tbody > tr');
  103. let spanList = document.querySelectorAll('div.layui-table-box > div.layui-table-body.layui-table-main > table > tbody > tr > td:nth-child(2) > div > p:nth-child(2) > span');
  104. let count = 0;
  105. for (let i = trList.length - 1; i >= 0; i--) {
  106. let span = trList[i].querySelector('td:nth-child(2) > div > p:nth-child(2) > span');
  107. let checkBox = trList[i].querySelector('td:nth-child(1) > div > div > i');
  108. const element = spanList[i];
  109. if (span.className.indexOf('green') == -1) {
  110. trList[i].remove();
  111. } else {
  112. checkBox.click();
  113. count++;
  114. }
  115. }
  116.  
  117. trList = document.querySelectorAll('div.layui-table-box > div.layui-table-body.layui-table-main > table > tbody > tr');
  118. for (let i = 0; i < trList.length; i++) {
  119. const element = trList[i];
  120. let divEle = trList[i].querySelector('td:nth-child(2) > div');
  121. let htmlStr = divEle.innerHTML;
  122. let newStr = htmlStr.replaceAll('p>', 'a>');
  123. divEle.innerHTML = newStr;
  124.  
  125. let otherDiv = trList[i].querySelector('td:nth-child(3) > div');
  126. let otherHTML = otherDiv.innerHTML;
  127. let otherNew = otherHTML.replaceAll('p>', 'a>');
  128. otherDiv.innerHTML = otherNew;
  129. }
  130.  
  131. let countSpan = document.querySelector('span.head.count');
  132. countSpan.textContent = count;
  133. }
  134.  
  135. function addButton() {
  136. let parent = document.querySelector('div.layui-table-tool > div.layui-table-tool-temp > div.layui-btn-group');
  137. let button = document.createElement('button');
  138. button.textContent = '过滤';
  139. button.title = '过滤绿色可用源';
  140. button.className = 'layui-btn layui-btn-sm layui-btn-normal';
  141. button.onclick = function () {
  142. beautifyShuYuan();
  143. }
  144.  
  145. let countSpan = document.createElement('span')
  146. countSpan.className = 'head count';
  147. parent.append(button);
  148. parent.append(countSpan);
  149. }
  150.  
  151. /**
  152. * Log the title and version at the front of the console.
  153. * @param {String} title title.
  154. * @param {String} version script version.
  155. */
  156. function logInfo(title, version) {
  157. console.clear();
  158. const titleStyle = 'color:white;background-color:#606060';
  159. const versionStyle = 'color:white;background-color:#1475b2';
  160. const logTitle = ' ' + title + ' ';
  161. const logVersion = ' ' + version + ' ';
  162. console.log('%c' + logTitle + '%c' + logVersion, titleStyle, versionStyle);
  163. }
  164. })();

QingJ © 2025

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