Created
December 12, 2020 04:41
-
-
Save dfang/ffbebf1eb14b48dee5bfa3cc830103be to your computer and use it in GitHub Desktop.
jd auto order
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name jd抢购 | |
// @namespace http://violentmonkey.github.io/ | |
// @version 0.1 | |
// @description jd 自动下单 | |
// @author dfang | |
// @match *://cart.jd.com/* | |
// @match *://item.jd.com/* | |
// @match *://trade.jd.com/* | |
// @grant none | |
// @license MIT | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let clickTime; | |
// 详情页面 自动加入到购物车 | |
if(location.hostname == 'item.jd.com') { | |
clickTime = window.prompt('🙊yo man! 输入秒杀时间🚀 格式如: 2018-08-15T00:00:00'); | |
const time1 = setInterval(() => { | |
const gap = new Date() - new Date(clickTime); | |
console.log(`/---------- 正在倒计时: 还有 ${-Math.floor(gap/(1000 * 60))} 分钟,开始点击----------/`); | |
if(gap >= 0) { | |
document.getElementsByClassName('submit-btn')[0].click(); | |
// 跳转到购物车页面 | |
window.location.href = "https://cart.jd.com/cart_index/" | |
// 购物车自动去结算 | |
if (location.hostname == 'cart.jd.com') { | |
const time2 = setInterval(() => { | |
const btn = document.getElementsByClassName('common-submit-btn')[0]; | |
if (btn) { | |
btn.click(); | |
} | |
}, 100); | |
} | |
// 提交订单页面 | |
if (location.hostname == 'trade.jd.com') { | |
setInterval(() => { | |
const btn = document.getElementsByClassName('checkout-submit')[0]; | |
if (btn) { | |
btn.click(); | |
} | |
}, 100); | |
} | |
} | |
const btn = document.getElementById('order-submit'); | |
if(btn) { | |
btn.click(); | |
} | |
}, 100); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment