NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @id oneplus_rusher // @name 一加手机抢购助手 // @namespace http://www.shendle.com/ // @version 0.9 // @description 抢购一加手机(4G内存,凯芙拉材质后盖),自动点击购买。 // @author Arniu Tseng <arniu2006@gmail.com> // @icon http://statics.oneplus.cn/v2/img/home/logo.png // @match http://rush.oneplus.cn/rush.html // @match http://rush.oneplus.cn/order.html // @require http://code.jquery.com/jquery-1.11.1.min.js // @grant none // ==/UserScript== // 选择后盖款式,默认为凯芙拉 function choose_cover(name) { name = name || '凯芙拉'; var selector = 'dd[data-name^="%"]'.replace(/%/, name), context = $('div.attr:nth-child(1)'); $(selector, context).click(); } // 选择机身容量, 默认为 4G function choose_model(size) { size = size || '4GRAM'; var selector = 'dd[data-name^="%"]'.replace(/%/, size), context = $('div.attr:nth-child(2)'); $(selector, context).click(); } // 获取开放购买时间,单位为毫秒 function timeleft_ms() { var fields = $('.lasttime').html() .split(/[\D:]+/g) .reverse(); var timeleft = 0; for (var i = 1; i < fields.length; i++) { var value = parseInt(fields[i]); switch (i) { case 1: timeleft += value; break; case 2: timeleft += value * 60; break; case 3: timeleft += value * 60 * 60; break; case 4: timeleft += value * 60 * 60 * 24; break; } } return timeleft * 1000; } // 计算轮训时间间隔,单位为毫秒 function timerush_ms() { if ($('#$buynowBtn').text() === '立即购买') { return Math.max(500, timeleft_ms() / 2); } else { return 24 * 60 * 60 * 1000; } } function log(message) { console.log(new Date().toLocaleString('en-GB') + ' : ' + message); } $(function() { choose_cover(); choose_model(); var count = 1; setTimeout(function () { setTimeout(arguments.callee, timerush_ms()); if ($('#buynowBtn').is('.open')) { log('Rush #' + count++); $('#buynowBtn').click(); } }, timerush_ms()); });