-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzbp_DevTools.user.js
292 lines (273 loc) · 8.33 KB
/
zbp_DevTools.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
// ==UserScript==
// @name 「Z-Blog」开发者工具(应用中心)
// @namespace https://www.wdssmq.com/
// @version 2.1
// @author 沉冰浮水
// @description 含订单搜索,附带隐藏未付订单,应用审核回显;
// @license MIT
// @null ----------------------------
// @contributionURL https://github.com/wdssmq#%E4%BA%8C%E7%BB%B4%E7%A0%81
// @contributionAmount 5.93
// @null ----------------------------
// @link https://github.com/wdssmq/userscript
// @link https://afdian.net/@wdssmq
// @link https://greasyfork.org/zh-CN/users/6865-wdssmq
// @null ----------------------------
// @noframes
// @match https://app.zblogcn.com/zb_system/admin/edit.php*id=*
// @match https://app.zblogcn.com/zb_users/plugin/AppBuy/shop/main.php*
// @match https://app.zblogcn.com/?id=*
// @match https://user.zblogcn.com/trade/money/payout
// @grant none
// ==/UserScript==
/* jshint esversion: 6 */
(function () {
"use strict";
const gm_name = "zbp_DevTools";
// ---------------------------------------------------
const _log = (...args) => console.log(`[${gm_name}]\n`, ...args);
// ---------------------------------------------------
let $ = null;
try {
$ = window.$ || unsafeWindow.$;
} catch (e) {
// _error(e);
}
function $n(e) {
return document.querySelector(e);
}
// ---------------------------------------------------
const fnElChange = (el, fn = () => { }) => {
const observer = new MutationObserver((mutationRecord, mutationObserver) => {
// _log('mutationRecord = ', mutationRecord);
// _log('mutationObserver === observer', mutationObserver === observer);
fn(mutationRecord, mutationObserver);
// mutationObserver.disconnect();
});
observer.observe(el, {
// attributes: false,
// attributeFilter: ["class"],
childList: true,
// characterData: false,
subtree: true,
});
};
// 前台编辑链接
(() => {
if ($ === null) return;
if ($(".app-content").text() === "") return false;
const edtLink =
"https://app.zblogcn.com/zb_system/admin/edit.php" +
location.search +
"&act=ArticleEdt";
const domLink = $(
"<a title=\"编辑\" target=\"_blank\" href=\"" + edtLink + "\">编辑</a>",
);
domLink
.css({
color: "darkgray",
"font-size": "14px",
"padding-left": "0.5em",
})
.hover(
function () {
$(this).css({
color: "#d60000",
});
},
function () {
$(this).css({
color: "darkgray",
});
},
);
$(".app-header-detail h3").append(domLink);
})();
// Ajax 回显自动审核
(() => {
if ($ === null) return;
let $p = $("#response3 dl p");
if ($p.length == 0 || $p.find("a").length == 1) {
return;
}
function fnGet(cb) {
$.ajax({
url: location.href,
type: "get",
success: function (data) {
let $el = $(data).find("#response3 dl a");
if ($el.attr("href")) {
cb($el.attr("href"));
}
console.log($el.attr("href"));
},
});
}
let i = 43;
let t = setInterval(() => {
$p.html(`自动审核中,请稍侯${i}`);
i--;
if (i % 13 == 0) {
fnGet((href) => {
$p.html(
`自动审核完毕,<a target="_blank" href="${href}">请点击此处查看。</a>`,
);
clearInterval(t);
});
}
if (i == 0) {
i = 47;
}
}, 1000);
})();
(() => {
if ($ === null) return;
// 移除指定的节点
function fnHide(t = "") {
let curHtml;
$("tr").each(function () {
curHtml = $(this).html();
if (/待付款/.test(curHtml)) $(this).remove();
if (t === "all") $(this).remove();
});
}
// 时间对比转天数
function fnTimeDiff(recent, past) {
let timeDiff = recent.getTime() - past.getTime();
let diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
return diffDays;
}
// 初始全局变量
const gobBase = {
oDate: null,
timeRan: {
recent: null,
past: null,
},
// 订单计数
intCount: 0,
// 价格总计
intTOL: 0,
// 金额累加,输入为金额字符串,扣除分成
add(amt) {
this.intTOL += parseFloat(amt) * 100 * 0.75;
},
diff() {
const intDiff = fnTimeDiff(this.timeRan.recent, this.timeRan.past);
return intDiff > 0 ? intDiff : 1;
},
view(t = "") {
let rltNum = 0;
switch (t) {
case "perDay":
rltNum = this.intTOL / this.diff() / 100;
break;
case "perMonth":
rltNum = this.intTOL / this.diff() / 100 * 30;
break;
default:
rltNum = this.intTOL / 100;
break;
}
return rltNum.toFixed(2);
},
};
// 实际调用
let gob;
// 搜索调用
function fnSearch(q) {
gob = Object.assign({}, gobBase);
_log(JSON.stringify(gob));
const regPat = new RegExp(q + ".+已付款", "");
fnHide("all");
fnAjax(1, regPat);
}
// Ajax 请求
function fnAjax(page, regPat) {
$.ajax({
url:
"https://app.zblogcn.com/zb_users/plugin/AppBuy/shop/main.php?page=" +
page,
type: "get",
success: function (data) {
if (/已付款/.test(data)) {
// if (/已付款/.test(data) && page < 2) {
// _log($(data));
let curHtml;
$(data)
.find("#divMain2 table tr")
.each(function () {
curHtml = $(this)
.html()
.replace(/[\n\s]+/g, " ");
if (regPat.test(curHtml) === true) {
// 匹配时间字符串
let mltDate = curHtml.match(/<td.*>([^<]+)<\/td> <td>已付款<\/td>/);
// 转换时间对象
gob.oDate = new Date(Date.parse(mltDate[1]));
_log(curHtml);
_log(gob.oDate);
// 日期区间
if (gob.timeRan.recent === null) {
gob.timeRan.recent = gob.oDate;
}
gob.timeRan.past = gob.oDate;
// 订单计数
gob.intCount++;
// 匹配金额字符串
// let mltAMT = curHtml.match(/<td>¥([^<]+)<\/td>/);
let mltAMT = curHtml.match(/<td>¥[^<]+\(([^<]+)\)<\/td>/);
// 金额累加
gob.add(mltAMT[1]);
// 添加节点
$("table:not(#tbStatistic) tbody").append(
"<tr>" + curHtml + "</tr>\n",
);
}
});
page++;
fnAjax(page, regPat);
$("#js-page").text(page);
} else {
$("#js-page").text("完成");
const strTR = `<tr>
<td colspan="2"></td>
<td>${gob.intCount}</td>
<td>${gob.view()}</td>
<td colspan="2">${gob.view("perDay")}/天 | ${gob.view("perMonth")}/30 天</td>
<td>天数:${gob.diff()}</td>
<td></td>
<td></td>
</tr>`;
$("table:not(#tbStatistic) tbody").prepend(
strTR,
);
// _log(gob);
} },
// end success
});
}
// 放置搜索框
$(".SubMenu").append(
"<input id=\"search\" style=\"float:left;margin-right: 2px;margin-top: 2px\" type=\"text\" value=\"\">" +
"<a href=\"javascript:;\" id=\"js-search\"><span class=\"m-left\">搜索</span></a>" +
"<span id=\"js-page\"></span>",
);
// 搜索触发
$("#js-search").click(function () {
const search = $("#search").val();
// alert(search);
fnSearch(search);
});
})();
(() => {
const $body = $n("body");
fnElChange($body, (mutationRecord, mutationObserver) => {
const $input = $n(".ivu-input-number-input");
const $amt = $n(".ivu-alert-message p b");
if ($input === null) return;
$input.value = $amt.innerText;
mutationObserver.disconnect();
});
})();
})();