Greasy Fork

Greasy Fork is available in English.

淘宝购物车抢拍

try to take over the world!

当前为 2018-05-04 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)


// ==UserScript==
// @name         淘宝购物车抢拍
// @namespace    http://killest.net/
// @version      1.1
// @description  try to take over the world!
// @author       killest
// @match        https://h5.m.taobao.com/*
// @match        https://h5.m.tmall.hk/*
// @match        https://*.alipay.com/*
// @require      https://code.jquery.com/jquery-latest.js
// @require      http://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js
// @grant        none
// ==/UserScript==
var bwtime = 20;//前置时间
var loginTimeout = 30;//登陆超时刷新时间 min
var d8;//抢拍时间
var IsRob = $.cookie('IsRob') === "true" ? true : false;
var Isasync = false;
var realTime;
var starttime;
var endtime;
var initsdtime_int = 0;//第一次获得的服务器时间
var thissdtime_int;
function syncTime()
{
    d8 = new Date();
    d8.setTime($.cookie("d8time"));//读取抢拍时间

    starttime = new Date().getTime();
    $.ajax({
        url: "https://t.alicdn.com/t/gettime?_ksTS=1523775092522_196",
        async: false,
        success: function (result)
        {


            endtime = new Date().getTime();
            console.log("耗时" + (endtime - starttime));
            console.log("结束获取时间" + new Date().getTime());
            //服务器时间
            var sd = new Date();
            sd.setTime(result.time * 1000);
            console.log("时间:" + sd.toLocaleString());
            console.log("d8时间:" + d8.toLocaleString());
            var ttx = d8 - sd;
            console.log("ttx:" + ttx);
            $.cookie('IsRob', true, { expires: 7 ,path: '/'});
            if (ttx < 0)//已过1
            {
                alert("时间已过");
                $.cookie('IsRob', false, { expires: 7,path: '/' });
                location.replace(location.href);
            }
            else if (ttx > 60 * 1000 * 10)//10分钟才同步
            {
                console.log("距离开始抢拍还要一段时间");
                setTimeout(() =>
                {
                    location.replace(location.href);
                }, 60 * 1000);
            }
            else if (ttx > 0) {
                if (initsdtime_int == 0) {
                    initsdtime_int = parseInt(result.time);
                }

                if (parseInt(result.time) == (initsdtime_int + 1)) {
                    console.log("同步时间完成");
                    var bwtime = 10;//前置时间
                    sd.setTime(result.time * 1000 - endtime + starttime - bwtime);

                    window.setTimeout(function ()
                    {
                        // alert("时间到");
                        console.log("时间到");
                        $(".btn").trigger("click");
                    }, d8 - sd);
                }
                else {
                    setTimeout(() =>
                    {
                        syncTime();
                    }, 20);
                }


            }


        },
        dataType: "jsonp"


    });
}
  if (window.location.href.indexOf("buyNow") > 0 && IsRob) {
            $("#submitOrder_1 > div.mui-flex.align-center > div.cell.fixed.action > div").trigger("click");
            window.setInterval(function () { $("#submitOrder_1 > div.mui-flex.align-center > div.cell.fixed.action > div").trigger("click"); }, 10);
    }
	
 if (window.location.href.indexOf("trade_pay.do") > 0 && IsRob) {
    $.cookie('IsRob', false, { expires: 7 ,path: '/'});
    var notification = new Notification("MSG:", {
        body: '已经抢拍成功~尽快支付'
    });
}

function xxx()
{
    Notification.requestPermission().then(function (result)
    {
        // result可能是是granted, denied, 或default.
        if (result != 'granted')
            alert('请允许桌面通知~');
    });
    alert("haha");
}
(function ()
{
    'use strict';
    Notification.requestPermission();
    //$(".shop").trigger("select");



    $(document).ready(function ()
    {





        if (window.location.href.indexOf("cart.html") > 0) {
            var elem = "#J_cartBuy > div > div:nth-child(2) > div.allItemv2 > div.footer > div > div > div.qx";


            if (IsRob) {
                var selectstr = "#" + $(".bundlev2")[0].id + " > div.shop > div > div > div.shopcb > p > label";
                $(selectstr).trigger("click");
                $(elem).after("<button class=\"btn\" id=\"startRob\"> 抢拍中... <botton>");

            }
            else {
                $(elem).after("<button class=\"btn\" id=\"startRob\"> 开始抢拍 <botton>");

            }
            if ($.cookie('robtime')) {
                $(elem).after("<input id=\"Robtime\" class=\"hj\" value=\"" + $.cookie('robtime') + "\"  type=\"text\"  ></input>");
            }
            else {
                $(elem).after("<input id=\"Robtime\" class=\"hj\" value=\"20:00:00\"  type=\"text\"  ></input>");
            }

            if (IsRob) {
                syncTime();
            }
            $(elem).after("<label class=\"major\">抢拍时间</label>");
            $("#startRob").click(function ()
            {
                if (IsRob) {
                    IsRob = false;
                    $.cookie('IsRob', false, { expires: 7 ,path: '/'});
                    $("#startRob").text("开始抢拍");
                }
                else {

                    var selectstr = "#" + $(".bundlev2")[0].id + " > div.shop > div > div > div.shopcb > p > label";
                    $(selectstr).trigger("click");

                    let d = new Date();
                    d8 = new Date();
                    var timestr = $("#Robtime").val();

                    var tts = timestr.split(":");
                    console.log(timestr);
                    if (tts.length != 3) {
                        alert("输入的时间有误 参考: 20:00:00  ");
                        return;
                    }

                    d8.setHours(parseInt(tts[0]));
                    d8.setMinutes(parseInt(tts[1]));
                    d8.setSeconds(parseInt(tts[2]));

                    let ttx = d8 - d;
                    if (ttx < 0)//已过10s
                    {
                        d8.setTime(d8.getTime() + 24 * 60 * 60 * 1000);


                    }
                    console.log("抢拍时间:" + d8.toLocaleString());
                    $.cookie('d8time', d8.getTime(), { expires: 7 });
                    IsRob = true;
                    $.cookie('robtime', $("#Robtime").val(), { expires: 7 });
                    $.cookie('IsRob', true, { expires: 7,path: '/' });
                    $("#startRob").text("抢拍中...");
                    syncTime();
                }


                // window.setTimeout(
                //     function(){
                //         var selectstr="#"+$(".bundlev2")[0].id+" > div.shop > div > div > div.shopcb > p > label";
                //         $(selectstr).trigger("click");
                //     },
                //     2000
                // );

            });


        }


    });


})();