最近要海淘,聽說轉運中國不錯,但是不開放注冊,只能通過海淘貝、什么值得買等網站發的邀請碼來進行注冊。無奈狼多肉少,總也搶不到。邀請碼如下圖:
但有時候,他是文字的。於是有了下面的代碼,方便我快速驗證所有的邀請碼。
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()"/>');
界面如下: