Skip to content

Commit a56bd42

Browse files
committed
Update jd_hd.js
1 parent af4855f commit a56bd42

1 file changed

Lines changed: 2 additions & 190 deletions

File tree

Script/jd_hd.js

Lines changed: 2 additions & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,6 @@ https?://.*\.moxigame\.cn url script-response-body https://raw.githubusercontent
1919
hostname = *.jd.com, *.*.jd.com, *.moxigame.cn
2020
*/
2121
const $ = new Env('京东助手');
22-
const clickClassName = $.getData('id77_vConsole_clickClassName') || '';
23-
const clickClassName2 = $.getData('id77_vConsole_clickClassName2') || '';
24-
const clickInterval = $.getData('id77_vConsole_clickInterval') || 70; // ms
25-
const clickNum = $.getData('id77_vConsole_clickNum') || 1; // 点击次数
26-
const cancelDisabled =
27-
$.getData('id77_vConsole_cancelDisabled') === 'yes' || false;
28-
const unClassName = $.getData('id77_vConsole_unClassName') || '';
29-
const inClassName = $.getData('id77_vConsole_inClassName') || '';
30-
const timingRunningTime = $.getData('id77_vConsole_timingRunningTime') || '';
3122

3223
let html = $response.body;
3324

@@ -70,16 +61,6 @@ try {
7061
}
7162
cookieListDom += `</ul>`;
7263

73-
let qgInfoDom = `
74-
<div id="QG">
75-
<div id="domList">当前选中DOM: <i>点击查询</i></div>
76-
<div>点击间隔: ${clickInterval}ms</div>
77-
<div>点击次数: ${clickNum}</div>
78-
<div>定时运行时间: ${timingRunningTime || '未设定'}</div>
79-
<div id="_time">倒计时: <i>N</i></div>
80-
</div>
81-
`;
82-
8364
let tools =
8465
`
8566
<div id="_btns">
@@ -140,10 +121,10 @@ try {
140121
background: #FFF;
141122
border-radius: 50px 0 0 50px;
142123
}
143-
.cks, #QG {
124+
.cks {
144125
padding: 1.1429em;
145126
}
146-
.cks li, #QG > div {
127+
.cks li {
147128
margin-bottom: 0.7143em;
148129
border: 0.0714em solid #ccc;
149130
padding: 0.3571em;
@@ -154,9 +135,6 @@ try {
154135
._btn.hide {
155136
display: none !important;
156137
}
157-
#domList i {
158-
color: #4092BA;
159-
}
160138
</style>
161139
${tools}
162140
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.1/js.cookie.min.js"></script>
@@ -248,7 +226,6 @@ try {
248226
window.vConsole = new VConsole();
249227
vConsole.setSwitchPosition(10, 50);
250228
const JDCKPlugin = new VConsole.VConsolePlugin("jd_cookie", "京东CK");
251-
const QGPlugin = new VConsole.VConsolePlugin("qg", "抢购工具");
252229
253230
JDCKPlugin.on("renderTab", function (callback) {
254231
const html = \`
@@ -257,13 +234,6 @@ try {
257234
258235
callback(html);
259236
});
260-
QGPlugin.on("renderTab", function (callback) {
261-
const html = \`
262-
${qgInfoDom}
263-
\`;
264-
265-
callback(html);
266-
});
267237
268238
JDCKPlugin.on("addTool", function (callback) {
269239
@@ -303,34 +273,6 @@ try {
303273
304274
callback(toolList);
305275
});
306-
307-
QGPlugin.on("addTool", function (callback) {
308-
309-
const toolList = [];
310-
const $dom = document.querySelector('#domList');
311-
312-
$dom.addEventListener('click', () => {
313-
vConsole.show();
314-
vConsole.showTab("default");
315-
const $clickDom = document.querySelector("${clickClassName}");
316-
console.info($clickDom);
317-
})
318-
319-
toolList.push({
320-
name: "开始执行",
321-
global: false,
322-
onClick: function (event) {
323-
vConsole.hide();
324-
// vConsole.showTab("network");
325-
const $clickDom = document.querySelector("${clickClassName}");
326-
327-
clickTask($clickDom);
328-
329-
},
330-
});
331-
332-
callback(toolList);
333-
});
334276
335277
JDCKPlugin.on('ready', function() {
336278
@@ -353,142 +295,12 @@ try {
353295
vConsole.addPlugin(JDCKPlugin);
354296
}
355297
356-
if("${clickClassName}".includes('.') || "${clickClassName}".includes('#')) {
357-
vConsole.addPlugin(QGPlugin);
358-
}
359-
360298
setTimeout(() => {
361299
console.log(window.location.href);
362300
363-
const $btns = document.querySelectorAll("button");
364-
btnTask($btns);
365-
366-
if ("${clickClassName}") {
367-
const $clickDom = document.querySelector("${clickClassName}");
368-
classNameTask($clickDom);
369-
}
370-
371-
if ("${timingRunningTime}" && "${timingRunningTime}" !== "") {
372-
const date = new Date();
373-
const separator = "/";
374-
375-
let nowMonth = date.getMonth() + 1;
376-
377-
let strDate = date.getDate();
378-
379-
if (nowMonth >= 1 && nowMonth <= 9) {
380-
nowMonth = "0" + nowMonth;
381-
}
382-
if (strDate >= 0 && strDate <= 9) {
383-
strDate = "0" + strDate;
384-
}
385-
386-
let strHour = date.getHours();
387-
388-
if (strHour >= 0 && strHour <= 9) {
389-
strHour = "0" + strHour;
390-
}
391-
392-
let taskDate = date.getFullYear() + separator + nowMonth + separator + strDate + " " + strHour + ":${timingRunningTime}";
393-
let endTime = new Date(taskDate);
394-
let needTask = endTime >= new Date() ? true : false;
395-
396-
if (document.querySelector("#_time")) initializeClock('#_time i', new Date(Date.parse(endTime) + 1 * 60 * 60 * 1000));
397-
398-
if (needTask) {
399-
setTimeout(() => clickTask($clickDom), new Date(taskDate).getTime() - Date.now());
400-
}
401-
}
402-
403301
},3000);
404302
405303
}
406-
407-
function clickTask($clickDom) {
408-
let $dom = $clickDom;
409-
async function* asyncGenerator() {
410-
let i = 0;
411-
const num = "${clickClassName2}" !== "" ? 1 : Number(${clickNum});
412-
while (i < num) {
413-
yield i++;
414-
}
415-
}
416-
417-
(async function() {
418-
for await (let num of asyncGenerator()) {
419-
let time = Number(${clickInterval}) * num;
420-
console.info("========" + num + "========");
421-
console.log($dom);
422-
423-
setTimeout(() => {
424-
btnTask($dom);
425-
classNameTask($dom);
426-
$dom.click();
427-
428-
if ("${clickClassName2}" !== "") {
429-
setTimeout(() => {
430-
const $dom2 = document.querySelector("${clickClassName2}");
431-
console.log($dom2);
432-
$dom2.click();
433-
});
434-
}
435-
}, time);
436-
}
437-
})();
438-
439-
}
440-
441-
function classNameTask ($dom) {
442-
if(!$dom) return;
443-
444-
if ("${unClassName}" !== "") {
445-
$dom.classList.remove("${unClassName}");
446-
}
447-
if ("${inClassName}" !== "") {
448-
$dom.classList.add("${inClassName}");
449-
}
450-
}
451-
452-
function btnTask ($dom) {
453-
if (${cancelDisabled}) {
454-
$dom.removeAttribute('disabled');
455-
}
456-
}
457-
458-
function getTimeRemaining(endTime) {
459-
const total = Date.parse(endTime) - Date.parse(new Date());
460-
const seconds = Math.floor((total / 1000) % 60);
461-
const minutes = Math.floor((total / 1000 / 60) % 60);
462-
const hours = Math.floor((total / (1000 * 60 * 60)) % 24);
463-
const days = Math.floor(total / (1000 * 60 * 60 * 24));
464-
465-
return {
466-
total,
467-
days,
468-
hours,
469-
minutes,
470-
seconds,
471-
};
472-
}
473-
474-
function initializeClock(className, endTime) {
475-
const $dom = document.querySelector(className);
476-
let timeInterval;
477-
478-
function updateClock() {
479-
const t = getTimeRemaining(endTime);
480-
481-
if (t.total <= 0) {
482-
clearInterval(timeInterval);
483-
} else {
484-
$dom.textContent = ('0' + t.minutes).slice(-2) + ':' + ('0' + t.seconds).slice(-2);
485-
}
486-
}
487-
488-
updateClock();
489-
timeInterval = setInterval(updateClock, 1000);
490-
}
491-
492304
</script>
493305
</html>
494306
`;

0 commit comments

Comments
 (0)