雙十一當(dāng)天考試,沒辦法去搶購東西,閑暇之余寫了一個京東秒殺搶購助手,幫助沒有時間的人搶一些想要的東西; 為什么叫小桃子版,因為頭像的小公主就是叫小桃子.@_@本來想做把腳本做成chrome擴(kuò)展插件的形式,讓大家用起來方便些,擴(kuò)展程序注入監(jiān)控畫面比較麻煩,試了兩次失敗了,平時比較忙,來不及實現(xiàn)了.使用腳本搶購,就當(dāng)鍛煉鍛煉自己的動手能力吧; 如果做成chrome擴(kuò)展就是這個樣子

本人博客原文鏈接 使用方式: 1:打開要搶購商品的詳細(xì)畫面,請注意網(wǎng)絡(luò)地址一定要是 item.jd.com開頭的詳細(xì)畫面,摁F12,打開開發(fā)者模式,選擇Console選項卡,把以下代碼粘貼在Console里面,回車執(zhí)行; 打開開發(fā)者模式
特別注意:被監(jiān)控的畫面標(biāo)簽頁一定要在前臺
代碼: var nIntervId;
var count = 1;
var goDate;
function go() {
console.log("小桃子 ^_^ 正在幫你搶購************* 刷新" + count + "次");
//console.log("host:" + window.location.hostname);
count++;
// iPhone X go set time
if (Date.now() >= new Date("2017-11-03 15:59:59")) {
console.log("開始搶購iPhone X" + Date.now());
// iphoneX 搶購
if ($(parent.frames[0].document).find("#choose-btn-ko").length == 1) {
console.log("(++++++++++++iphoneX 搶購");
var sku = window.location.pathname.replace(/[^0-9]/ig, "");
var ref = "//cart.jd.com/gate.action?pid=" + sku + "&pcount=1&ptype=1";
console.log("https:" + ref);
//5089237
$(parent.frames[0].document).find("#choose-btn-ko").attr("href", ref);//
parent.frames[0].document.getElementById("choose-btn-ko").click();
return;
}
//預(yù)約搶購
if ($(parent.frames[0].document).find("#btn-reservation").length == 1) {
console.log("(++++++++++++正在預(yù)約搶購");
parent.frames[0].document.getElementById("btn-reservation").click();
return;
}
//秒殺
if ($(parent.frames[0].document).find("#InitCartUrl").length == 1) {
console.log("(++++++++++++正在秒殺");
parent.frames[0].document.getElementById("InitCartUrl").click();
return;
}
//去購物車結(jié)算
if ($(parent.frames[0].document).find("#GotoShoppingCart").length == 1) {
console.log("(++++++++++++正在去購物車結(jié)算");
parent.frames[0].document.getElementById("GotoShoppingCart").click();
}
//去結(jié)算
if ($(parent.frames[0].document).find(".submit-btn").length == 1) {
console.log("(++++++++++++正在去結(jié)算");
//只提交我搶購的商品
//var sku = window.location.pathname.replace(/[^0-9]/ig, "");
//$("#toggle-checkboxes_up").trigger("click");
//全不選擇
//parent.frames[0].document.getElementById("toggle-checkboxes_up").click();
//$(parent.frames[0].document).find('input:checkbox').attr("checked",false);
//$(parent.frames[0].document).find("input:checkbox[value^='"+sku+"']").trigger("click");
//$(parent.frames[0].document).find("input:checkbox[value^='"+sku+"']").attr("checked",true);
parent.frames[0].document.getElementsByClassName("submit-btn")[0].click();
}
//提交訂單order-submit
if ($(parent.frames[0].document).find("#order-submit").length == 1) {
console.log("(++++++++++++正在提交訂單");
//$(parent.frames[0].document).find(".payment-item item-selected online-payment")
//在線支付
parent.frames[0].document.getElementById("order-submit").click();
}
}
}
function rewrite(current) {
fr4me = '<frameset cols=\'*\'>\n<frame src=\'' + current + '\'/>';
fr4me += '</frameset>';
with (document) { write(fr4me); void (close()) };
}
//注入sql
rewrite(window.location.href);
//這里需要注意的是,prompt有兩個參數(shù),前面是提示的話,后面是當(dāng)對話框出來后,在對話框里的默認(rèn)值
var d = prompt("請輸入搶購開始時間", "2017-11-03 15:59:59");
//如果返回的有內(nèi)容
if (d) {
try {
goDate = new Date(d);
console.log("設(shè)定時間成功:" + goDate);
alert("監(jiān)控期間,請保持標(biāo)簽頁在最前面");
//go(); 0.25秒執(zhí)行一次
nIntervId = setInterval("go()", 250);
}
catch (e) {
alert("時間格式不正確,請使用yyyy-MM-dd hh:mm:ss格式,精確到秒, 請重試");
}
}
else {
alert("請搶購時間, 請重重試");
}
/*
clearInterval(nIntervId);//停止監(jiān)控
*/
|