Last active
December 23, 2015 17:09
-
-
Save kevintop/6666945 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
if (!window.ed10010) { | |
$('#buyForm').submit(function(event){ | |
var price = parseFloat($('.lineThrough').text().substring(1)); | |
if (isNaN(price)) { | |
window.alert('找不到原价,刷新页面后重试'); | |
window.location.reload(); | |
return false; | |
} | |
console.log('原价 ' + price); | |
localStorage.setItem('original', price); | |
localStorage.setItem('ed10010', JSON.stringify($(this).serializeArray())); | |
localStorage.setItem('hm10010', JSON.stringify(paramInfo)); | |
return true; | |
}); | |
window.ed10010 = true; | |
} | |
$('#submit_btn_id').click(); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var fakedata; | |
try { | |
fakedata = JSON.parse(localStorage.getItem('ed10010')); | |
if (!fakedata) throw 'null'; | |
} catch (e) { | |
window.alert('找不到订单信息。在商品页面需要用buy.js购买,并且此脚本需要在订单页面执行'); | |
return; | |
} | |
var count = 1; | |
var makeid = function() { | |
var text = ""; | |
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
for( var i=0; i < 3; i++ ) | |
text += possible.charAt(Math.floor(Math.random() * possible.length)); | |
return text; | |
} | |
var prefix = makeid(); | |
var paramString = ''; | |
var first = true; | |
$.each(fakedata, function(i, obj) { | |
if (first) { | |
first = false; | |
} else { | |
paramString += '&'; | |
} | |
paramString += (obj.name + '=' + obj.value); | |
}); | |
var openNew = function() { | |
console.log('打开新窗口 ' + prefix + '_' + count); | |
window.open('http://mall.10010.com/mall-web/GoodsDetail/promtlyBuy?' + paramString, prefix + '_' + count); | |
count++ | |
}; | |
$('#header div.logo img').click(openNew).click(openNew).click(openNew).click(openNew).click(openNew); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var fakedata = JSON.parse(localStorage.getItem('ed10010')); | |
var numInfo = localStorage.getItem('hm10010') ? JSON.parse(localStorage.getItem('hm10010')) : {}; | |
var original = localStorage.getItem('original'); | |
var numPrice = 0; | |
var numberChecker; | |
var pingNumber = function() { | |
if (window.stopRobot) { | |
clearInterval(numberChecker); | |
return; | |
} | |
logOnTitle('问候新号码'); | |
$.ajax({ | |
url: 'http://mall.10010.com/mall-web/GoodsDetailAjax/occupyNumberAjax', | |
type: 'POST', | |
data: numInfo, | |
error: null | |
}); | |
}; | |
$.each(fakedata, function(i, obj) { | |
if (obj.name == 'numberFee') { | |
numPrice = obj.value / 1000; | |
} else if (obj.name == 'custTag' && obj.value == '1') { | |
console.log('新用户'); | |
numberChecker = setInterval(pingNumber, 120000); | |
} | |
}); | |
original -= numPrice; | |
var expected = original*0.6 + numPrice; | |
console.log('手机原价 ' + original + ', 号码价格 ' + numPrice + ', 期待价格不大于 ' + expected); | |
var $newPage; | |
var lastTitle = ''; | |
var logOnTitle = function(msg) { | |
console.log(msg); | |
document.title = msg + ' <--' + lastTitle; | |
lastTitle = msg; | |
}; | |
var onPostReturn = function(data) { | |
$newPage = $(data); | |
$('span#Price').attr('goodsPrice', $newPage.filter('div').find('span#Price').attr('goodsPrice')); | |
$('span#Price').html($newPage.filter('div').find('span#Price').html()); | |
var price = parseFloat($newPage.filter('div').find('span#Price').attr('goodsPrice')); | |
if (isNaN(price)) { | |
logOnTitle('找不到价格'); | |
deferTrigger(); | |
} else if (price > expected) { | |
logOnTitle('价格太高 ' + price + ' > ' + expected); | |
deferTrigger(); | |
} else { | |
$('#orderSubmitForm #_m_token').attr('value', $newPage.filter('#orderSubmitForm').find('#_m_token').attr('value')); | |
$('#orderSubmitForm #_m_state').attr('name', $newPage.filter('#orderSubmitForm').find('#_m_state').attr('name')); | |
$('#orderSubmitForm #_m_state').attr('value', $newPage.filter('#orderSubmitForm').find('#_m_state').attr('value')); | |
logOnTitle('发现价格 ' + price + ', 下单!'); | |
$('#orderSubmitForm').submit(); | |
} | |
}; | |
var deferTrigger = function() { | |
var d = new Date(); | |
var interval = 59; | |
switch (d.getHours()) { | |
case 8: | |
case 12: | |
case 19: | |
if (d.getMinutes() > 56) | |
interval = !!window.robotInterval ? window.robotInterval : 0; | |
break; | |
case 9: | |
case 13: | |
case 20: | |
interval = !!window.robotInterval ? window.robotInterval : 0; | |
break; | |
default: | |
} | |
logOnTitle('下次刷新间隔 ' + interval + ' 秒'); | |
if (interval == 0) { | |
trigger(); | |
} else { | |
setTimeout(trigger, interval * 1000); | |
} | |
}; | |
var onPostError = function(request, textStatus, errorThrown) { | |
logOnTitle('刷新失败: ' + textStatus); | |
deferTrigger(); | |
}; | |
var trigger = function() { | |
if (window.stopRobot) { | |
logOnTitle('手动结束!'); | |
return; | |
} | |
logOnTitle('刷新'); | |
$.ajax({ | |
url: 'http://mall.10010.com/mall-web/GoodsDetail/promtlyBuy', | |
type: 'POST', | |
data: fakedata, | |
timeout: 25000, | |
success: onPostReturn, | |
error: onPostError | |
}); | |
}; | |
var preSubmitted = false; | |
var preSubmit = function() { | |
$('#orderSubmitForm').submit(function(event) { | |
if (preSubmitted) return true; | |
if (!$('#orderSubmitForm #paramStr').val()) { | |
logOnTitle('信息不完整,无法保存下单数据'); | |
} else { | |
logOnTitle('保存下单数据'); | |
$('#orderSubmit').removeClass('clicked') | |
preSubmitted = true; | |
trigger(); | |
} | |
return false; | |
}); | |
orderSubmit(); | |
}; | |
delete window.stopRobot; | |
preSubmit(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment