Tampermonkey写超星登录脚本

Tampermonkey写超星登录脚本

出于超星登录的频率过高及懒癌发作的原因,再加上想水一篇文章就开干了
登录界面如下
Tampermonkey写超星登录脚本_第1张图片

登录界面每次都要选择地区和学校,很麻烦
Tampermonkey写超星登录脚本_第2张图片

1-创建新脚本

这是Tampermonkey添加新脚本后的默认代码

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        http://passport2.chaoxing.com/login*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
})();

​ @name 是脚本名称

​ @match 这一行是指定脚本生效的网址,如果有多个,再拷贝一行改掉网址就好了。可以使用通配符,比如http://passport2.chaoxing.com/* ,表示http://passport2.chaoxing.com/站点下全生效。

2-查看网站元素

​ 账号和密码自动填写很简单,控制台查看之后可见
账号
Tampermonkey写超星登录脚本_第3张图片
​ 由此我们直接在脚本的自执行函数中写填写代码

(function() {
    'use strict';
    // Your code here...
    document.getElementById("unameId").value='***';//自动输入账号
    document.getElementById("passwordId").value='***';//自动输入密码
})();

​ 当选择不同机构时,发现这一部分的数据会改变,因此对其进行尝试
此处需选择好你所需的机构查看下列具体值
机构

(function() {
    'use strict';
    document.getElementById("unameId").value='***';//自动输入账号
    document.getElementById("passwordId").value='***';//自动输入密码

    document.getElementById("fid").value='262';//切换学校id
    document.getElementById("fidname").value='南昌大学';//切换学校名

    // Your code here...
})();
3-尝试

​ 后续刷新登录发现有效果,至于验证码填写我无能为力了

4-代码
// ==UserScript==
// @name         超星
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        http://passport2.chaoxing.com/login*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    document.getElementById("unameId").value='*  **';//自动输入账号
    document.getElementById("passwordId").value='***';//自动输入密码
	// 此处需选择好你所需的机构查看下列具体值
    document.getElementById("fid").value='262';//切换学校id
    document.getElementById("fidname").value='南昌大学';//切换学校名

    // Your code here...
})();

你可能感兴趣的:(js)