这是演示 模拟京东抢购 的js脚本,demo而已,具体商品自行修改
1 登录 网页京东,进入https://item.jd.com/10024680695127.html,选好参数
2 打开开发者模式,插入如下代码
count= 1
nIntervId= 0
stop= 0
var goDate
function start ( ) {
if ( stop== 1 ) {
clearInterval ( nIntervId) ;
return
}
if ( Date. now ( ) < goDate) {
return
}
console. log ( " ^_^ 正在帮你抢购************* 刷新" + count + "次" + "host:" + window. location. hostname) ;
count++ ;
if ( $ ( parent. frames[ 0 ] . document) . find ( "#InitCartUrl" ) . length== 1 ) {
console. log ( "(++++++++++++正在秒杀" ) ;
parent. frames[ 0 ] . document. getElementById ( "InitCartUrl" ) . click ( )
return
}
if ( $ ( parent. frames[ 0 ] . document) . find ( "#GotoShoppingCart" ) . length == 1 ) {
console. log ( "(++++++++++++正在去购物车结算" ) ;
parent. frames[ 0 ] . document. getElementById ( "GotoShoppingCart" ) . click ( )
var head = document. head || document. getElementsByTagName ( 'head' ) [ 0 ] ;
var style = document. createElement ( 'meta' ) ;
style. setAttribute ( "http-equiv" , "Content-Security-Policy" ) ;
style. setAttribute ( "content" , "upgrade-insecure-requests" ) ;
head. appendChild ( style) ;
}
if ( $ ( parent. frames[ 0 ] . document) . find ( ".common-submit-btn" ) . length == 1 ) {
console. log ( "(++++++++++++正在去结算" ) ;
parent. frames[ 0 ] . document. getElementsByClassName ( "common-submit-btn" ) [ 0 ] . click ( )
}
if ( $ ( parent. frames[ 0 ] . document) . find ( "#order-submit" ) . length == 1 ) {
console. log ( "(++++++++++w++正在提交订单" ) ;
parent. frames[ 0 ] . document. getElementById ( "order-submit" ) . click ( ) ;
stop= 1
}
}
function rewrite ( current) {
fr4me = '<frameset cols=\'*\'>\n<frame src=\'' + current + '\'/>' ;
fr4me += '</frameset>' ;
with ( document) { write ( fr4me) ; void ( close ( ) ) } ;
}
rewrite ( window. location. href) ;
var d = prompt ( "请输入抢购开始时间" , '2021-1-19 20:53:14' ) ;
if ( d) {
try {
goDate = new Date ( d) ;
console. log ( "设定时间成功:" + goDate) ;
alert ( "监控期间,请保持标签页在最前面" ) ;
nIntervId = setInterval ( "start()" , 250 ) ;
}
catch ( e ) {
alert ( "时间格式不正确,请使用yyyy-MM-dd hh:mm:ss格式,精确到秒, 请重试" ) ;
}
}
else {
alert ( "请抢购时间, 请重重试" ) ;
}
3
4
5
6