🏠 Home 

「Z-Blog」开发者工具(本地)

自动填写 Z-Blog 应用的配置项


ติดตั้งสคริปต์นี้?
สคริปต์ที่แนะนำของผู้เขียน

คุณอาจชื่นชอบ 「Z-Blog」开发者工具(应用中心)


ติดตั้งสคริปต์นี้
  1. // ==UserScript==
  2. // @name 「Z-Blog」开发者工具(本地)
  3. // @namespace https://www.wdssmq.com/
  4. // @version 0.4
  5. // @author 沉冰浮水
  6. // @description 自动填写 Z-Blog 应用的配置项
  7. // @null ----------------------------
  8. // @contributionURL https://github.com/wdssmq#%E4%BA%8C%E7%BB%B4%E7%A0%81
  9. // @contributionAmount 5.93
  10. // @null ----------------------------
  11. // @link https://github.com/wdssmq/userscript
  12. // @link https://afdian.net/@wdssmq
  13. // @link https://greasyfork.org/zh-CN/users/6865-wdssmq
  14. // @null ----------------------------
  15. // @include http://*/zb_users/plugin/AppCentre/plugin_edit.php*
  16. // @include http://*/zb_users/plugin/AppCentre/theme_edit.php*
  17. // @include http://*/zb_system/admin/index.php?act=PluginMng*
  18. // @grant GM_getValue
  19. // @grant GM_setValue
  20. // ==/UserScript==
  21. /* jshint esversion:6 */
  22. (function () {
  23. "use strict";
  24. const $ = window.jQuery || unsafeWindow.jQuery || function () {};
  25. // console.log($);
  26. // 初始化配置
  27. const config = GM_getValue("config", {});
  28. if (JSON.stringify(config) === "{}") {
  29. GM_setValue("config", {
  30. appUrl: "//jq.qq.com/?_wv=1027&k=555hND5",
  31. appAdapted: "162210",
  32. appPHPVer: "5.6",
  33. appDesc: "置百丈玄冰而崩裂,掷须臾池水而漂摇。",
  34. authName: "沉冰浮水",
  35. authEmail: "wdssmq@qq.com",
  36. authUrl: "https://www.wdssmq.com",
  37. });
  38. }
  39. // console.log(config);
  40. (() => {
  41. if (location.pathname.indexOf("AppCentre") === -1) {
  42. return;
  43. }
  44. /**
  45. * @param {string} selc 文本选择器
  46. * @param {string} value 值
  47. * @param {boolean} f 强制覆盖
  48. */
  49. function fnFill(selc, value, f = 0) {
  50. if ($(selc).val() === "" || f) {
  51. $(selc).val(value);
  52. }
  53. }
  54. const curUsr = [$("div.username").text(), $("#app_author_name").val()];
  55. // 只在新建时填写
  56. if (curUsr[0].indexOf(curUsr[1]) > -1) {
  57. fnFill("#app_author_name", config.authName, 1);
  58. fnFill("#app_author_email", config.authEmail, 1);
  59. fnFill("#app_author_url", config.authUrl, 1);
  60. fnFill("#app_adapted", config.appAdapted, 1);
  61. fnFill("#app_phpver", config.appPHPVer, 1);
  62. fnFill("#app_path", "main.php", 1);
  63. fnFill("#app_include", "include.php", 1);
  64. }
  65. // 值为空时填写
  66. fnFill("#app_url", config.appUrl);
  67. fnFill("#app_description", config.appDesc);
  68. const app_id = $("#app_id").val();
  69. if (/LinksManage/.test(app_id)) {
  70. fnFill("#app_phpver", "5.4", 1);
  71. }
  72. })();
  73. (() => {
  74. if (location.pathname !== "/zb_system/admin/index.php") {
  75. return;
  76. }
  77. /**
  78. *
  79. * @param {str} string 日期文本
  80. * @param {int} d 指定天数内的,或者指定天数前的;
  81. */
  82. function DateMinus(string, d = [5, ####]) {
  83. const sDate = new Date(string.replace(/-/g, "/"));
  84. const nDate = new Date();
  85. const intDiff = nDate.getTime() - sDate.getTime();
  86. const day = parseInt(intDiff / (1000 * 60 * 60 * 24));
  87. return day <= d[0] || day >= d[1];
  88. }
  89. // location.pathname
  90. $("tr").each(function () {
  91. const curHtml = $(this).html();
  92. if ($(this).find("th").length > 0) {
  93. return;
  94. }
  95. const strDate = $(this).find(".td20 + .td20").html().trim();
  96. const strAuthor = $(this).find(".td20 a").text().trim();
  97. if (DateMinus(strDate) && strAuthor == config.authName) {
  98. console.log(strDate, strAuthor);
  99. $(this).css({ color: "red" }).insertAfter("table tbody tr:first-child");
  100. }
  101. if (/Todo|mzGrunt|FileIgnore|xnxf_SubMenu/.test(curHtml)) {
  102. $(this).css({
  103. color: "cornflowerblue",
  104. });
  105. }
  106. });
  107. })();
  108. })();