利用Tampermonkey chrome插件写脚本抢课以及交大选课插件 |
您所在的位置:网站首页 › tampermonkey脚本怎么写 › 利用Tampermonkey chrome插件写脚本抢课以及交大选课插件 |
去年无意间有看过一款交大选课插件,觉得现在的学生都好NIUbility,为了选课能搞出一个chrome插件。今天又看到一个学生为了在学校抢课又写了一个抢课的脚本。真的不佩服,不禁感慨,我的校园生活怎么就浪费了呢。
选用了tampermonkey插件来写脚本。 在谷歌应用商店搜索tampermonkey并安装,如果谷歌打不到,就到http://www.cnplugins.com/office/tampermonkey/下载 安装完后选择添加脚本,绑定执行脚本的页面,这里有个坑,关于要不要require jquery的问题。 如果绑定的页面中已引用jq了,就不要添加require jq了,否则会冲突 如果没有,则记得添加jq 然后写脚本就是了! 以下是针对我抢课页面的脚本代码,写这篇博客的过程中,课已经抢到了,哈哈哈~
(function() {
'use strict';
//return;
$('table tr').each(function(){
var lesson = $(this).find("td").eq(1).children('span').text();
if(lesson == 'Java技术' || lesson == '有效共同技巧(MOOC)'){
if($(this).children('td').eq(7).children('a').text() != ''){
$(this).children('td').eq(7).children('a').trigger('click');
console.log(window.frames[0].document.querySelectorAll('input[id=contentParent_dgData_ImageButton1_0]'));
setTimeout(function(){
$(window.frames[0].document.querySelectorAll('input[id=contentParent_dgData_ImageButton1_0]')).click();
$('#contentParent_dgData_ImageButton1_0').click();
console.log('chose class now !');
}, 2000);
}
else{
location.reload();
}
}
});
// setTimeout(location.reload(), 10000);
// Your code here...
})();
123456789101112131415161718192021222324252627
代码由公司的大神帮忙写出来的,其中有些地方现在还不是很了解,因为涉及到页面中动态加载的内容,用普通的jq选择器没法选择到新增的元素,因此用到了 $(window.frames[0].document.querySelectorAll('input[id=contentParent_dgData_ImageButton1_0]')).click(); 1这段神奇的代码。有空我还是得好好学习下原生的javascript,值得学习的地方还很多呀。 另外找到了Electsys++ 交大选课插件的下载地址:http://www.cnplugins.com/fuzhu/electsys-jiaodaxuankechajian/ 希望可以帮助到在校抢课的学生哦,加油! |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |