最近要海淘,听说转运中国不错,但是不开放注册,只能通过海淘贝、什么值得买等网站发的邀请码来进行注册。无奈狼多肉少,总也抢不到。邀请码如下图:

但有时候,他是文字的。于是有了下面的代码,方便我快速验证所有的邀请码。
function runCode(){
var strCode = $('#tbCodes').val();
var codes = strCode.split('\n');
$.each(codes,function(i,code){
var win = window.open(window.location.href,"_blank");
win.addEventListener('load',function(){
console.log('loaded')
//debugger;
$('#aspnetForm').find(':text,:password').each(function(i,n){
var id = this.id;
var val = $(this).val();
if(id == 'code'){
val = code;
}
win.$('#' + id).val(val);
});
win.$('#aspnetForm').get(0).submit();
});
});
}
$(document.body).append('<textarea id="tbCodes"></textarea><input type="button" value="GO" onclick="runCode()"/>');
界面如下:
