刷票大战(二)——自动填充功能实现

来源:互联网 发布:小米4支持4g网络吗 编辑:程序博客网 时间:2024/05/29 04:32

前言:正如上篇所讲,万恶的投票网站竟然投一次要选十个人,MY GOD,要选比她选票少的人,等投个几十票下来,眼都看花了。作为程序猿这当然是无法忍受的,想办法让网页自动勾选选手,于是乎找到了TemperMonkey这个插件可以自主写JS代码添加到指定网页中。从而实现一些特定功能。


相关文章:

1、《刷票大战(一)——突破IP限制》
2、《刷票大战(二)——自动填充功能实现》
3、《刷票大战(三)——C#自动POST数据》


万恶的投票网站截图:



一、安装TemperMonkey插件

方法一:google应用商店

进入google应用商店搜,如果打不开网页,你就需要翻墙啦,至于翻墙软件,到这里去找《刷票战略(一)——突破IP限制

方法二:从TemperMonkey.crx文件加载

当然为了google把这个软件撤销,我已经将其打包,当前的版本是3.7.48,下载地址:http://download.csdn.net/detail/harvic880925/7477095(附安装方法)

二、新建脚本

脚本如下:

完成功能:选中某十个选手,随机生成身份证号。

// ==UserScript==// @name       示例// @namespace  http://localhost/1/vote.htm// @version    0.1// @description  enter something useful// @match     http://localhost/1/*.*// @require    http://code.jquery.com/jquery-1.11.0.min.js// @copyright  2012+, You// ==/UserScript==document.getElementById("ch63").checked=true;document.getElementById("ch64").checked=true;document.getElementById("ch60").checked=true;document.getElementById("ch47").checked=true;document.getElementById("ch48").checked=true;document.getElementById("ch33").checked=true;document.getElementById("ch27").checked=true;document.getElementById("ch24").checked=true;document.getElementById("ch20").checked=true;document.getElementById("ch25").checked=true;javascript:document.getElementsByTagName('BODY')[0].scrollTop=document.getElementsByTagName('BODY')[0].scrollHeight;var type=Math.floor(Math.random()*1000000);//生成0-9的随机数var pepel="412402197806"+type;$("input[name='cid']").val(pepel);


三、网页及源码

我把网页下载下来了,大家只需要将其中的“1”文件夹放在自建的服务器下,比如我使用的apache+php,就将其放在htdocs文件夹下,在chrome里输入http://localhost/1/vote.htm
就可以看到,页面自动勾选了指定的十个选手,并生成了身份证号。

对于为何要这样写JS代码,呃……,会JS的一点难度没有,不会JS的应该看不懂……

 

PS:当然可以写ajax代码自动实现POST数据,网上的一个段代码,大家可以参考

原文地址:http://www.cnblogs.com/dnawo/archive/2012/01/19/2326227.html

            $.ajax({                type : "POST",                url  : "Login.asp?r=" + Math.random(),                data : "txtUsn=" + usn + "&txtUsp=" + usp + "&txtPassCode=" + code,                async: false,                success : function(msg){                    responseText = msg;                    if(responseText.indexOf("登录成功") != -1)                    {                        alert("登录成功.尝试次数:" + i);                        location.href = "Login.asp";                    }                }            });

 

相关网址:《如何使用tampermonkey?》:http://jingyan.baidu.com/article/fb48e8be5b9d1d6e622e14f2.html

源码下载:http://download.csdn.net/detail/harvic880925/7477299


请大家尊重原创者版权,转载请标明出处:http://blog.csdn.net/harvic880925/article/details/29843127,不胜感激!!!!!



0 0
原创粉丝点击