Skip to content

Commit fb4eece

Browse files
committed
Update jd_hd.js
1 parent 7e238ee commit fb4eece

1 file changed

Lines changed: 83 additions & 10 deletions

File tree

Script/jd_hd.js

Lines changed: 83 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ https://active.jd.com/forever/btgoose url script-response-body jd_hd.js
1313
hostname = *.jd.com, *.*.jd.com
1414
*/
1515
const $ = new Env('京东助手');
16+
const clickClassNames = $.getData('id77_vConsole_clickClassNames') || '';
17+
const clickInterval = $.getData('id77_vConsole_clickInterval') || 70; // ms
18+
const clickTime = $.getData('id77_vConsole_clickTime') || 30 * 1000; // ms
1619

1720
let html = $response.body;
1821

@@ -44,13 +47,25 @@ try {
4447
sku = arr.length != 0 ? arr[1] : '';
4548

4649
let cookieListDom = `<ul class="cks">`;
47-
for (let index = 0; index < cookies.length; index++) {
48-
const cookie = cookies[index];
49-
const pin = cookie.match(/pt_pin=(.+?);/)[1];
50-
cookieListDom += `<li id="_${pin}" onclick="changeCookie('${cookie}')">${pin}</li>`;
50+
51+
const isJD = url.includes('jd.com') || url.includes('jingxi.com');
52+
if (isJD) {
53+
for (let index = 0; index < cookies.length; index++) {
54+
const cookie = cookies[index];
55+
const pin = cookie.match(/pt_pin=(.+?);/)[1];
56+
cookieListDom += `<li id="_${pin}" onclick="changeCookie('${cookie}')">${pin}</li>`;
57+
}
5158
}
5259
cookieListDom += `</ul>`;
5360

61+
let qgInfoDom = `
62+
<div id="QG">
63+
<div id="domList">当前选中DOM: <i>点击查询</i></div>
64+
<div>点击间隔: ${clickInterval}ms</div>
65+
<div>点击时长: ${clickTime / 1000}s</div>
66+
</div>
67+
`;
68+
5469
let tools =
5570
`
5671
<div id="_btns">
@@ -110,10 +125,10 @@ try {
110125
background: #FFF;
111126
border-radius: 50px 0 0 50px;
112127
}
113-
.cks {
128+
.cks, #QG {
114129
padding: 1.1429em;
115130
}
116-
.cks li {
131+
.cks li, #QG > div {
117132
margin-bottom: 0.7143em;
118133
border: 0.0714em solid #ccc;
119134
padding: 0.3571em;
@@ -124,6 +139,9 @@ try {
124139
._btn.hide {
125140
display: none !important;
126141
}
142+
#domList i {
143+
color: #4092BA;
144+
}
127145
</style>
128146
${tools}
129147
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.1/js.cookie.min.js"></script>
@@ -156,7 +174,7 @@ try {
156174
const other = {
157175
path: '/',
158176
expires: 7,
159-
secure: true
177+
// secure: true
160178
};
161179
162180
const domains = [
@@ -215,18 +233,26 @@ try {
215233
window.vConsole = new VConsole();
216234
vConsole.setSwitchPosition(10, 50);
217235
const JDCKPlugin = new VConsole.VConsolePlugin("jd_cookie", "京东CK");
236+
const QGPlugin = new VConsole.VConsolePlugin("qg", "抢购工具");
218237
219238
JDCKPlugin.on("renderTab", function (callback) {
220-
var html = \`
239+
const html = \`
221240
${cookieListDom}
222241
\`;
223242
224243
callback(html);
225244
});
245+
QGPlugin.on("renderTab", function (callback) {
246+
const html = \`
247+
${qgInfoDom}
248+
\`;
249+
250+
callback(html);
251+
});
226252
227253
JDCKPlugin.on("addTool", function (callback) {
228254
229-
var toolList = [];
255+
const toolList = [];
230256
toolList.push({
231257
name: "领券页面",
232258
global: false,
@@ -262,6 +288,47 @@ try {
262288
263289
callback(toolList);
264290
});
291+
292+
QGPlugin.on("addTool", function (callback) {
293+
294+
const toolList = [];
295+
const $dom = document.querySelector('#domList');
296+
let intervalId;
297+
298+
$dom.addEventListener('click', () => {
299+
vConsole.show();
300+
vConsole.showTab("default");
301+
const $clickDoms = document.querySelectorAll("${clickClassNames}");
302+
console.info($clickDoms)
303+
})
304+
305+
toolList.push({
306+
name: "开始执行",
307+
global: false,
308+
onClick: function (event) {
309+
vConsole.showTab("network");
310+
const $clickDoms = document.querySelectorAll("${clickClassNames}");
311+
for (let n = 0; n < $clickDoms.length; n++) {
312+
const $element = $clickDoms[n];
313+
314+
intervalId = setInterval(() => $element.click(),${Number(
315+
clickInterval
316+
)});
317+
318+
setTimeout(() => clearInterval(intervalId), ${Number(clickTime)});
319+
}
320+
},
321+
},{
322+
name: "结束执行",
323+
global: false,
324+
onClick: function (event) {
325+
vConsole.showTab("network");
326+
clearInterval(intervalId)
327+
},
328+
});
329+
330+
callback(toolList);
331+
});
265332
266333
JDCKPlugin.on('ready', function() {
267334
@@ -280,7 +347,13 @@ try {
280347
281348
});
282349
283-
vConsole.addPlugin(JDCKPlugin);
350+
if (${isJD}) {
351+
vConsole.addPlugin(JDCKPlugin);
352+
}
353+
354+
if("${clickClassNames}".includes('.') || "${clickClassNames}".includes('#')) {
355+
vConsole.addPlugin(QGPlugin);
356+
}
284357
285358
setTimeout(() => {
286359
console.log(window.location.href);

0 commit comments

Comments
 (0)