淘宝购物车抢拍

try to take over the world!

  1.  
  2. // ==UserScript==
  3. // @name 淘宝购物车抢拍
  4. // @namespace http://killest.net/
  5. // @version 1.8
  6. // @description try to take over the world!
  7. // @author killest
  8. // @match https://h5.m.taobao.com/*
  9. // @match https://h5.m.tmall.hk/*
  10. // @match https://*.alipay.com/*
  11. // @match https://*.taobao.com/*
  12. // @match https://*.tmall.com/*
  13. // @require https://code.jquery.com/jquery-latest.js
  14. // @require http://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js
  15. // @grant none
  16. // ==/UserScript==
  17. var bwtime = 100;//前置时间
  18. var loginTimeout = 30;//登陆超时刷新时间 min
  19. var Isweb=false;
  20. if (window.location.href.indexOf("h5.m.taobao.com") > 0)
  21. {
  22. Isweb=true;
  23. }
  24. var d8;//抢拍时间
  25. var IsRob = $.cookie('IsRob') === "true" ? true : false;
  26. var Isasync = false;
  27. var realTime;
  28. var starttime;
  29. var endtime;
  30. var initsdtime_int = 0;//第一次获得的服务器时间
  31. var thissdtime_int;
  32. function syncTime()
  33. {
  34. d8 = new Date();
  35. d8.setTime($.cookie("d8time"));//读取抢拍时间
  36.  
  37. starttime = new Date().getTime();
  38. $.ajax({
  39. url: "https://t.alicdn.com/t/gettime?_ksTS=1523775092522_196",
  40. async: false,
  41. success: function (result)
  42. {
  43.  
  44.  
  45. endtime = new Date().getTime();
  46. console.log("耗时" + (endtime - starttime));
  47. console.log("结束获取时间" + new Date().getTime());
  48. //服务器时间
  49. var sd = new Date();
  50. sd.setTime(result.time * 1000);
  51. console.log("时间:" + sd.toLocaleString());
  52. console.log("d8时间:" + d8.toLocaleString());
  53. var ttx = d8 - sd;
  54. console.log("ttx:" + ttx);
  55. $.cookie('IsRob', true, { expires: 7 ,path: '/'});
  56. if (ttx < 0)//已过1
  57. {
  58. alert("时间已过");
  59. $.cookie('IsRob', false, { expires: 7,path: '/' });
  60. location.replace(location.href);
  61. }
  62. else if (ttx > 60 * 1000 * 10)//10分钟才同步
  63. {
  64. console.log("距离开始抢拍还要一段时间");
  65. setTimeout(() =>
  66. {
  67. location.replace(location.href);
  68. }, 60 * 1000);
  69. }
  70. else if (ttx > 0) {
  71. if (initsdtime_int == 0) {
  72. initsdtime_int = parseInt(result.time);
  73. }
  74.  
  75. if (parseInt(result.time) == (initsdtime_int + 1)) {
  76. console.log("同步时间完成");
  77.  
  78. sd.setTime(result.time * 1000 + endtime - starttime + bwtime);
  79.  
  80. window.setTimeout(function ()
  81. {
  82. // alert("时间到");
  83. console.log("时间到");
  84. if(Isweb)
  85. {
  86. $(".btn").trigger("click");
  87. }
  88. else
  89. {
  90. $("#J_Go > span").trigger("click");
  91. }
  92.  
  93.  
  94. }, d8 - sd);
  95. }
  96. else {
  97. setTimeout(() =>
  98. {
  99. syncTime();
  100. }, 20);
  101. }
  102.  
  103.  
  104. }
  105.  
  106.  
  107. },
  108. dataType: "jsonp"
  109.  
  110.  
  111. });
  112. }
  113. if (window.location.href.indexOf("buyNow") > 0 ) {
  114.  
  115. // $("#submitOrder_1 > div.mui-flex.align-center > div.cell.fixed.action > div > span").trigger("click");
  116. //setTimeout setInterval
  117. window.setTimeout(function () {
  118. $("#submitOrder_1 > div.mui-flex.align-center > div.cell.fixed.action > div > span").trigger("click");
  119. window.setInterval(function () {
  120. $("#submitOrder_1 > div.mui-flex.align-center > div.cell.fixed.action > div > span").trigger("click");
  121.  
  122. }, 25);
  123. }, 15);
  124.  
  125.  
  126. }
  127. console.log(window.location.href);
  128. if (window.location.href.indexOf("confirm_order") > 0 ) {
  129. // console.log( $("#submitOrder_1 > div > a.go-btn").html());
  130.  
  131. $(".go-btn").trigger("click");
  132. window.setInterval(function () {
  133. $(".go-btn").trigger("click");
  134. var submit=$('.go-btn');
  135. if(submit.length !== 0){
  136. submit[0].click();
  137. submit[0].trigger("click");
  138. }
  139. }, 10);
  140. }
  141. if (window.location.href.indexOf("trade_pay.do") > 0 && IsRob) {
  142. $.cookie('IsRob', false, { expires: 7 ,path: '/'});
  143. var notification = new Notification("MSG:", {
  144. body: '已经抢拍成功~尽快支付'
  145. });
  146. }
  147.  
  148. function SetNotification()
  149. {
  150. Notification.requestPermission().then(function (result)
  151. {
  152. // result可能是是granted, denied, 或default.
  153. if (result != 'granted')
  154. alert('请允许桌面通知~');
  155. });
  156.  
  157. }
  158. (function ()
  159. {
  160. 'use strict';
  161. if(Notification.permission != 'granted')
  162. {
  163. SetNotification();
  164. }
  165. //Notification.requestPermission();
  166. //$(".shop").trigger("select");
  167.  
  168.  
  169.  
  170. $(document).ready(function ()
  171. {
  172. console.log("Isweb:"+Isweb);
  173.  
  174.  
  175.  
  176.  
  177. if (window.location.href.indexOf("cart.htm") > 0) {
  178. if(Isweb)
  179. {
  180. var elem = "#J_cartBuy > div > div:nth-child(2) > div.allItemv2 > div.footer > div > div > div.qx";
  181. var selectstr = "#" + $(".bundlev2")[0].id + " > div.shop > div > div > div.shopcb > p > label";
  182. }
  183. else
  184. {
  185.  
  186. var elem = "#J_FloatBar > div.float-bar-wrapper > div.operations > a.J_BatchShare";
  187. if($(".J_Order")[0])
  188. {
  189. var selectstr = "#" + $(".J_Order")[0].id + " > div.J_ItemHead.shop.clearfix > div > div > label";
  190. }
  191. else
  192. {
  193. var selectstr = "#" + $(".J_CheckBoxShop")[0].id + " > div.J_ItemHead.shop.clearfix > div > div > label";
  194. }
  195.  
  196. }
  197.  
  198.  
  199.  
  200. if (IsRob) {
  201.  
  202. $(selectstr).trigger("click");
  203. $(elem).after("<button class=\"btn\" id=\"startRob\" > 抢拍中... <botton>");
  204.  
  205. }
  206. else {
  207. $(elem).after("<button class=\"btn\" id=\"startRob\"> 开始抢拍 <botton>");
  208.  
  209. }
  210. if ($.cookie('robtime')) {
  211. $(elem).after("<input id=\"Robtime\" class=\"hj\" style='width:70px' value=\"" + $.cookie('robtime') + "\" type=\"text\" ></input>");
  212. }
  213. else {
  214. $(elem).after("<input id=\"Robtime\" class=\"hj\" value=\"20:00:00\" style='width:70px' type=\"text\" ></input>");
  215. }
  216.  
  217. if (IsRob) {
  218. syncTime();
  219. }
  220. $(elem).after("<label class=\"major\"style='color:red' >抢拍时间</label>");
  221. $("#startRob").click(function ()
  222. {
  223. if (IsRob) {
  224. IsRob = false;
  225. $.cookie('IsRob', false, { expires: 7 ,path: '/'});
  226. $("#startRob").text("开始抢拍");
  227. }
  228. else {
  229.  
  230.  
  231.  
  232.  
  233. $(selectstr).trigger("click");
  234.  
  235. let d = new Date();
  236. d8 = new Date();
  237. var timestr = $("#Robtime").val();
  238.  
  239. var tts = timestr.split(":");
  240. console.log(timestr);
  241. if (tts.length != 3) {
  242. alert("输入的时间有误 参考: 20:00:00 ");
  243. return;
  244. }
  245.  
  246. d8.setHours(parseInt(tts[0]));
  247. d8.setMinutes(parseInt(tts[1]));
  248. d8.setSeconds(parseInt(tts[2]));
  249.  
  250. let ttx = d8 - d;
  251. if (ttx < 0)//已过10s
  252. {
  253. d8.setTime(d8.getTime() + 24 * 60 * 60 * 1000);
  254.  
  255.  
  256. }
  257. console.log("抢拍时间:" + d8.toLocaleString());
  258. $.cookie('d8time', d8.getTime(), { expires: 7 });
  259. IsRob = true;
  260. $.cookie('robtime', $("#Robtime").val(), { expires: 7 });
  261. $.cookie('IsRob', true, { expires: 7,path: '/' });
  262. $("#startRob").text("抢拍中...");
  263. syncTime();
  264. }
  265.  
  266.  
  267. // window.setTimeout(
  268. // function(){
  269. // var selectstr="#"+$(".bundlev2")[0].id+" > div.shop > div > div > div.shopcb > p > label";
  270. // $(selectstr).trigger("click");
  271. // },
  272. // 2000
  273. // );
  274.  
  275. });
  276.  
  277.  
  278. }
  279. else if(window.location.href.indexOf("newOn_desc") > 0)
  280. {
  281. //setTimeout setInterval
  282. window.setInterval(function () {
  283. var newonnode;
  284. var newurl;
  285. if(window.location.href.indexOf("tmall")> 0)
  286. {
  287. newonnode=$("#J_ShopSearchResult > div > div.J_TItems > div:nth-child(1) > dl:nth-child(1) > dd.detail > a");
  288. newurl = newonnode.attr("href");
  289. }
  290. else
  291. {
  292.  
  293. newonnode=$("#J_ShopSearchResult > div > div.shop-hesper-bd.grid > div:nth-child(2) > dl:nth-child(1) > dd.detail > a");
  294. newurl = newonnode.attr("href");
  295. }
  296. newurl="https:"+newurl;
  297. newurl = $.trim (newurl.replace("&amp;","&"));
  298. console.log(newurl);
  299. if(newonnode.text()!="" && newonnode.text()!= $.cookie("newnode") )
  300. {
  301.  
  302. $.cookie('newnode', newonnode.text(), { expires: 7 ,path: '/'});
  303. var notification = new Notification("MSG:", {
  304. body: newonnode.text(),
  305. icon: 'http://img.alicdn.com/favicon.ico'
  306. });
  307. notification.onclick = function() {
  308. window.open(newurl);
  309. }
  310. }
  311. else
  312. {
  313. location.replace(location.href);
  314. }
  315.  
  316. },5000);
  317.  
  318.  
  319.  
  320. }
  321.  
  322. });
  323.  
  324.  
  325. })();
  326.  
  327.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址