// ==UserScript==
// @name 淘宝、天猫、聚划算、京东、苏宁、魅族抢购助手v2
// @namespace Aice.Fu_gwTools
// @version 0.1.50
// @description 淘宝、天猫、聚划算、京东、苏宁、魅族自动抢购工具,支持淘宝、天猫、聚划算、京东、苏宁易购、苏宁香港、魅族的商品页面抢购、购物车抢购,在非抢购页面支持淘宝、天猫、京东、苏宁易购隐藏优惠券领取及历史价格查看。
// @include /http(?:s|)://(?:detail|item)\.(?:taobao|tmall)\.(?:[^./]+)/item.htm/
// @include https://chaoshi.tmall.com/*
// @include https://chaoshi.detail.tmall.com/*
// @include https://detail.tmall.hk/*
// @include https://buy.tmall.com/order/*
// @include https://buy.taobao.com/*
// @include https://cart.tmall.com/*
// @include https://cart.taobao.com/*
// @include https://s.click.taobao.com*
// @include https://buy.tmall.com/order/confirmOrderWap.htm*
// @include https://buy.taobao.com/auction/order/confirm_order.htm*
// @include https://buy.tmall.com/auction/order/confirm_order.htm*
// @include https://buy.liangxinyao.com/order/confirm_order.htm*
// @include https://detail.liangxinyao.com/*
// @include https://cart.jd.com/*
// @include */item.jd.com/*
// @include *//item.jd.hk/*
// @include https://trade.jd.com/shopping/order/*
// @include https://plogin.m.jd.com*
// @include https://m.jd.com/*
// @include https://wqdeal.jd.com*
// @include https://wqs.jd.com*
// @include https://wq.jd.com/*
// @include https://marathon.jd.com*
// @include */product.suning.com/*
// @include https://shopping.suning.com/cart.do*
// @include https://shopping.suning.com/order.do*
// @include https://shopping.hksuning.com*
// @include https://product.hksuning.com*
// @include https://detail.meizu.com/item*
// @include https://ordercenter.meizu.com/order/*
// @require https://code.jquery.com/jquery-latest.js
// @grant GM_xmlhttpRequest
// @grant GM_setValue
// @grant GM_getValue
// @grant unsafeWindow
// @connect gwdang.com
// @connect ubja.vip
// @connect alicdn.com
// @connect api.m.taobao.com
// @connect jd.com
// @connect quan.suning.com
// @author Aice.Fu
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
var myCon = '
';
var myConSN = '';
var myConJD = '';
//var myConJDMb = ' 购物助手 By Aice.Fu 开始倒计时 开始时间 提前 ms 微信支付 京东支付 ';
var myConJDCart = '';
var myConCart = '';
var ifLj = null;
var frmId = 0;
var btnBuy = null;
var realTime;
var starttime;
var endtime;
var initsdtime_int = 0;//第一次获得的服务器时间
var thissdtime_int;
var d8;//抢购时间
var cyce = 100; // 多少毫秒点击一次
var bwtime = 100;//前置时间
var gostart = 0;
var btnCart= null;
var ifYhq = 0;
var chk = 1;
var goodsId = null;
var skuId =null;
var sjid = null ;
var goBtn = 0;//执行抢购按钮
var allck = null;//购物车全选
var ifRef = 0; //是否刷新
var mqBfTim = 3;//盲抢提前刷新时间
var qzxd = 0 //强制下单
var yhqid = "771280092";
//历史价格提交参数
var pdata =null;
var pbeginTime=null;
var picdata =null;
var fm = null;
var buyTop = 1 //页面提交次数上限 不同页面提交次数不同
var buyPl = 250//页面执行的频率
var timeUrl = null;//时间同步
//Loading
var _PageHeight = document.documentElement.clientHeight,
_PageWidth = document.documentElement.clientWidth;
var _LoadingTop = _PageHeight > 61 ? (_PageHeight - 61) / 2 : 0,
_LoadingLeft = _PageWidth > 215 ? (_PageWidth - 215) / 2 : 0;
var _LoadingHtml = '';
var froUrl = localStorage.getItem('locUrl');
froUrl = froUrl==null?"":froUrl;
var mqMd = GM_getValue('mqmd');
ifRef = GM_getValue("ref");
if(ifRef==1 | ifRef == null){
GM_setValue("ref",0);
}
cyce = GM_getValue("Acyce");
if(cyce=="undefined" | cyce == null){
cyce=100;
}
goBtn = GM_getValue("goBtn");
if(goBtn=="undefined" | goBtn == null){
goBtn=100;
}
qzxd = GM_getValue("qzxd");
var AiceQqscp = document.getElementById("AiceQgscp");
if (AiceQqscp!== null && typeof(AiceQqscp) === 'object') {
$("#AiceQqscp").remove();
return;
}
if(window.location.origin == "https://detail.tmall.com" || window.location.origin == "https://chaoshi.detail.tmall.com" || window.location.origin == "https://detail.tmall.hk"||window.location.origin == "https://detail.liangxinyao.com"){
var fdiv = getTargetByTAV('div','class','tb-sku');//'tb-action tm-clear');
fdiv.id='J_Dtl';
$('#J_Dtl').append(myCon);
ifLj = getTargetByTAV('div','class','tb-btn-wait');
btnBuy =getTargetById('J_LinkBuy');
goodsId=/(?:&|\?)id=(\d+)/.exec(window.location.href)[1] ;
var fur = 0;
if (myCon.indexOf("myweb/tgj")) fur = window.location.href.indexOf('mm_'+yhqid)==-1 ;
if (fur && window.location.href!=froUrl) {
getYhqurl(goodsId,"",3,2);
}
if (qzxd==0){
getTargetById("AiceQxd").checked = false;
}else{
getTargetById("AiceQxd").checked = true;
}
GM_setValue("goodsId","0");
buyTop = 4;
buyPl = 500;
mqMd = 0;
frmId = 1;
}
if(window.location.origin == "https://item.taobao.com"){
$('#J_isku').append(myCon);
ifLj = getTargetByTAV('div','class','tb-btn-wait');
btnBuy =getTargetByTAV('a','class','J_LinkBuy');
goodsId=/(?:&|\?)id=(\d+)/.exec(window.location.href)[1] ;
//if ((window.location.href.indexOf('mm_'+yhqid)==-1)&&(window.location.href!=froUrl)) {
fur = 0;
if (myCon.indexOf("myweb/tgj")) fur = window.location.href.indexOf('mm_'+yhqid)==-1 ;
if (fur&&window.location.href!=froUrl) {
getYhqurl(goodsId,"",3,2);
}
if (qzxd==0){
getTargetById("AiceQxd").checked = false;
}else{
getTargetById("AiceQxd").checked = true;
}
GM_setValue("goodsId","0");
buyTop = 4;
buyPl = 500;
mqMd = 0;
frmId = 2;
}
if(window.location.origin == "https://cart.taobao.com"){
$('#J_Search').append(myConCart);
buyTop = 1;
buyPl = 500;
frmId = 3;
}
if(window.location.origin == "https://cart.tmall.com"){
$('#mallSearch').append(myConCart);
buyTop = 1;
buyPl = 500;
frmId = 4;
}
if(window.location.origin == "https://item.jd.com"||window.location.origin == "https://item.jd.hk"){
$('#choose-btns').append(myConJD);
goodsId= /(\d+)\.html/.exec(window.location.href)[1] ;
var purl = /item\.jd\.(?:[^./]+)\/(\d+)\.html/.exec(window.location.href)
if (purl != null && (window.location.href.indexOf('?')==-1)&&(window.location.href!=froUrl)) {
getYhqurl(goodsId,"",2,2);
}
if (qzxd==0){
getTargetById("AiceQxd").checked = false;
}else{
getTargetById("AiceQxd").checked = true;
}
GM_setValue("goodsId","0");
if (getTargetById("AiceQxd").checked){
//GM_setValue("goodsId","0");
getTargetById("AiceQxda").href="https://wqs.jd.com/order/s_confirm_miao.shtml?sceneval=2&scene=jd&isCanEdit=1&commlist=,,1,"+ goodsId;
btnBuy= getTargetById("AiceQxda");
GM_setValue("qzxd",0);
buyTop = 10;
buyPl = 250;
}else{
// iphoneX 抢购
if (getTargetById("choose-btn-ko")!== null && typeof(getTargetById('btn-choose-btn-ko')) === 'object') {
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);
btnBuy = document.getElementById("choose-btn-ko");
btnBuy.href = ref;
}
//预约抢购
if (getTargetById("btn-reservation")!== null && typeof(getTargetById('btn-reservation')) === 'object') {
console.log("(++++++++++++正在预约抢购");
btnBuy = document.getElementById("btn-reservation");
}
//秒杀
if (getTargetById('InitCartUrl')!== null && typeof(getTargetById('InitCartUrl')) === 'object') {
console.log("(++++++++++++正在秒杀");
btnBuy = document.getElementById("InitCartUrl");
}
buyTop = 1;
buyPl = 500;
}
mqMd = 0;
frmId = 5;
}
if(window.location.origin == "https://cart.jd.com"){
if(window.location.href.indexOf('https://cart.jd.com/addToCart.html')!=-1){
//去购物车结算
if (getTargetById("GotoShoppingCart")!== null && typeof(getTargetById('GotoShoppingCart')) === 'object'){
console.log("(++++++++++++正在去购物车结算");
btnBuy = getTargetById("GotoShoppingCart");
btnBuy.click();
}
return;
}
var Search = getTargetByTAV('div','class','w w1 header clearfix');
Search.id = "AiceSearch"
$('#AiceSearch').append(myConJDCart);
buyTop = 1;
buyPl = 500;
frmId = 6;
}
if(window.location.origin == "https://product.suning.com"){
goodsId= /(\d+)\.html/.exec(window.location.href)[1];
sjid = /(\d+)/.exec(window.location.href)[1];
if ((window.location.href.indexOf('utm_source=union')==-1)&&window.location.href!=froUrl) {
getYhqurl(goodsId,sjid,4,2);
}
var snDiv = getTargetByTAV('div','class','mainbtns clearfix');
snDiv.id = "AiceDiv"
$('#AiceDiv').append(myConSN);
btnBuy =getTargetById('buyNowAddCart');
buyTop = 1;
buyPl = 500;
mqMd = 0;
frmId = 7;
}
if(window.location.origin == "https://product.hksuning.com"){
goodsId= /(\d+)\.html/.exec(window.location.href)[1];
sjid = /(\d+)/.exec(window.location.href)[1];
if ((window.location.href.indexOf('utm_source=union')==-1)&&window.location.href!=froUrl) {
getYhqurl(goodsId,sjid,4,2);
}
var snhkDiv = getTargetByTAV('div','class','main-btns');
snhkDiv.id = "AiceDiv"
$('#AiceDiv').append(myConSN);
btnBuy =getTargetByTAV('li','class','btn-dark-buy');
buyTop = 1;
buyPl = 500;
mqMd = 0;
frmId = 7;
}
if(window.location.origin == "https://shopping.suning.com" && window.location.href.indexOf('cart.do')!=-1 ){
var SearchSn = getTargetByTAV('div','class','cart-search');
SearchSn.id = "AiceSearch"
$('#AiceSearch').append(myConCart);
buyTop = 1;
buyPl = 500;
frmId = 8;
}
if(window.location.origin == "https://shopping.hksuning.com" && window.location.href.indexOf('cart1')!=-1){
var SearchSnhk = getTargetByTAV('div','class','ng-header-box');
SearchSnhk.id = "AiceSearch"
$('#AiceSearch').append(myConCart);
buyTop = 1;
buyPl = 500;
frmId = 8;
}
if(window.location.origin == "https://wqdeal.jd.com" || window.location.origin == "https://wqs.jd.com" ){
mqMd = 0;
frmId = 9;
}
if (window.location.href.indexOf("https://buy.tmall.com/order/confirmOrderWap.htm")!=-1){
mqMd = 0;
frmId = 10;
}
if(window.location.href.indexOf("https://detail.meizu.com/item")!=-1){
var mzDiv = getTargetByTAV('div','class','property-buy');
mzDiv.id = "AiceDiv"
$('#AiceDiv').append(myConSN);
btnBuy =getTargetById('J_btnBuy');
buyTop = 1;
buyPl = 500;
mqMd = 0;
frmId = 11;
}
var ckhtml="";
if(window.location.origin == "https://s.click.taobao.com"){
ckhtml=$(":root").html().replace("top.location","self.location");
var czz = /
${sBody}