12306买票的脚本,成功抢到几张卧铺.

// ==UserScript==
// @name       12306
// @namespace  12306
// @version    0.1
// @description  enter something useful
// @match     https://dynamic.12306.cn/*
// @require        http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
// @copyright  2012+, You
// ==/UserScript==

//var dom = $(window.frames['main'].document); var btn = dom.find('#submitQuery'); var dt = dom.find(''); var interval = setInterval(function(){ btn.click(); if() },100);


//验证码
var code = $('input[name=randCode]'); 
 
//查询按钮
var btn = $('#submitQuery');
 
if(btn.length == 0 && code == 0) 
{ 
    return;
}

//输入验证码后自动下单
code.keyup(function(){  
    if($(this).val().length == 4)
    {
        $('.long_button_u').last().focus();
    }
}) 

//自动查询
$('').insertAfter(btn);

$('#auto').click(function(){ this.disabled = true; auto()}); 

function check()
{ 
    if($('.btn130_2').length > 0)
    {
        //自动预定
        $('.btn130_2').click();
        alert('有票了!');
        clearInterval(interval);
    }
}
var interval ;

//自动查询并预定
function auto()
{ 
    var interval = setInterval(function(){ 
        btn.click();
        check();
    },100);
}

你可能感兴趣的:(电脑技术)