已停更 ,更多脚本可见 Greasy Fork官网
地址如下 ↓ ↓ ↓ ↓
https://greasyfork.org/zh-CN
// ==UserScript==
// @name Uer/U校园/UTALK/网课答案显示/自动填入
// @namespace MrDgbot
// @version 2.0.8
// @description [√自动填入答案【可关闭】【默认延迟0.5秒】][√窗口显示答案][√作业与测试][√视听说单元测试][√UTALK]【禁止对源码进行修改,发布,禁止抄袭任意代码】(未适配的请联系,免费用户有5积分可以使用必修类,测试类内容需要在主页或脚本内的充值按钮获得积分方可使用)
// @author MrDgbot
// @compatible Chrome
// @match *://ucontent.unipus.cn/_pc_default/pc.html?*
// @match *://ucontent.unipus.cn/_utalk_default/pc.html?*
// @match *://uexercise.unipus.cn/uexercise*
// @match *://u.unipus.cn/user/student/homework*
// @match *://sso.unipus.cn/sso/login*
// @match *://u.unipus.cn/*
// @match *://ucamapi.unipus.cn/*
// @connect ljtion.work
// @connect ucamapi.unipus.cn
// @grant GM_xmlhttpRequest
// @grant GM.deleteValue
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_info
// @grant unsafeWindow
// @run-at document-start
// @require https://unpkg.com/sweetalert/dist/sweetalert.min.js
// @supportURL https://greasyfork.org/zh-CN/scripts/397517/feedback
// ==/UserScript==
var url = window.location.href;
//自动登入
var auto_login = 0;
//if (url.indexOf("ucontent.unipus.cn") < 0) return;
var _self = unsafeWindow,
xtoken = localStorage.getItem("jwtToke"),
turl = "http://og.ljtion.work/api/",
pageFirst = _self.pageFirst,
page = _self.page,
open_id = '',
$ = null,
none = '测试key不能为空,请详细阅读
【脚本描述】!',
//如果需要关闭自动答题把isinput的0改成1
setting = {
'utoken': '',
'isinput': 1,
'istest': 1,
'isagree': 1,
'timeout': '2000',
'score': '',
'show': '1',
'showb': '2',
'testurl': '',
'fromurl': '',
'testdata': '',
'url1' : 'https://ucontent.unipus.cn',
cache: {
count: 0,
type: 0,
mouse_x: -1,
mouse_y: -1
}
},
view = {};
function initView() {
view.top = $(
'' +
//''+
'' +
'Uer Help' +
'' +
'' +
'
' +
'' +
'
' +
'积分: ' +
'' +
'
' +
'' +
' +
'' +
'参数修改后自动保存' +
'' +
'' +
'' +
'' +
'' +
''
);
view.answerView = view.top.find('#answerContent');
view.info = view.top.find('#info');
view.div_main = view.top.find('#div_main');
view.showb = view.top.find('#div_foot');
view.top.appendTo('body').delegate('input', 'input change', function (event) {
if (this.value.match(/^\*+$/)) return;
let name = $(this).attr('name');
GM_setValue(name, this.value);
setting[name] = this.value;
console.log("修改完毕", GM_getValue(name, this.value), event.type)
getscore();
if (event.type == 'change') msg('配置保存成功,即时生效');
}).delegate('[name=utoken]', 'focus blur', function (event) {
$('#utoken').val('');
this.value = setting.utoken.replace(/(\S)/g, event.type == 'focusin' ? '$1' : '*');
}).delegate('button', 'click', function (e) {
e.stopImmediatePropagation();
e.stopPropagation();
e.preventDefault();
let name = $(this).attr('name');
if (name == 'cleanlog'){
$('#answer_log').html('');
layer.tips('清除完毕', '#cleanlog');
}
if (name == 'show') {
setting.show = GM_getValue('show');
$(this).html(setting.show ? '隐藏' : '显示');
setting.show ? GM_setValue('show', 0) : GM_setValue('show', 1);
view.answerView.slideToggle();
view.showb.slideToggle();
}
if (name == 'showb') {
setting.show = GM_getValue('showb');
$(this).html(setting.show ? '隐藏' : '显示');
setting.show ? GM_setValue('showb', 0) : GM_setValue('showb', 1);
view.showb.slideToggle();
}
if (name == 'jsindex') {
window.open("https://greasyfork.org/zh-CN/scripts/397517", "_blank");
}
if (name == 'changekey') {
$('#utoken').attr("disabled",false);
layer.tips('已解除锁定', '#utoken');
}
if (name == 'copykey') {
copyToClipboard(GM_getValue('utoken'))
layer.tips('复制成功', '#copykey');
}
if (name == 'dtbutton') {
setting.isinput = GM_getValue('isinput');
$(this).html(setting.isinput ? '开启普通自动答题' : '关闭普通自动答题');
console.log(GM_getValue('isinput'))
setting.isinput ? GM_setValue('isinput', 0) : GM_setValue('isinput', 1);
}
if (name == 'cz') {
let key = GM_getValue('utoken');
url = _self.location.href;
if (url.indexOf("u.unipus.cn") != -1) {
if(key){
layer.open({
title: '温馨提示'
,content: '充值的KEY是否为:
'+GM_getValue('utoken')
,time: 2000
,end: function(){
window.open("http://pay.ljtion.work/?token=" + setting.utoken, "_blank");
}
});
}else{
layer.open({
title: '温馨提示'
,content: 'Key错误,请勿擅自更改,如无KEY请清空后刷新加载'
,btnAlign: 'c'
,yes: function(){
$('#utoken').html('');
GM_setValue('utoken','');
window.location.reload();
}
});
}
} else {
alert("请不要在题目中点击充值,去教材主页点击")
}
//window.open("http://uspay.hurric.cn/?token=" + setting.utoken, "_blank");
}
if (name == 'showscore') {
getscore();
layer.tips('积分信息更新成功', '#showscore');
//msg("积分信息更新成功");
}
}).find('input').each(function () {
let type = $(this).attr('type'),
name = $(this).attr('name');
if (type == 'radio') {
this.checked = setting[name] == this.value;
} else if (name == 'score') {
this.value = setting[name]
} else if (name == 'utoken') {
this.value = setting[name].replace(/\S/g, '*');
} else {
this.value = setting[name];
}
});
//getxtoekn();
if (setting.utoken) {
msg('最新公告/常见问题','red')
msg('脚本正在运行');
} else {
console.log(setting.utoken);
getxtoken();
msg('欢迎使用脚本
答案将在页面加载三秒后出现
【脚本描述】
【交流群】', 'red');
}
addViewMouseListener()
}
function addViewMouseListener() {
view.top.bind('mousedown', function (event) {
//获取鼠标按下的时候左侧偏移量和上侧偏移量
setting.cache.view_x = $(this).position().left;
setting.cache.view_y = $(this).position().top;
setting.cache.mouse_x = event.originalEvent.clientX;
setting.cache.mouse_y = event.originalEvent.clientY;
console.log(setting.cache.mouse_x, setting.cache.mouse_y, setting.cache.view_x, setting.cache.view_y)
});
$(document).bind('mousemove', function (event) {
//计算出现在的位置是多少
if (setting.cache.mouse_x == -1) return;
if (setting.cache.mouse_y - setting.cache.view_y > view.top.height() - view.div_main.height()) return;
let new_position_left = event.originalEvent.clientX - setting.cache.mouse_x + setting.cache.view_x,
new_position_top = event.originalEvent.clientY - setting.cache.mouse_y + setting.cache.view_y;
//加上边界限制
if (new_position_top < 0) {//当上边的偏移量小于0的时候,就是上边的临界点,就让新的位置为0
new_position_top = 0;
}
//如果向下的偏移量大于文档对象的高度减去自身的高度,就让它等于这个高度
if (new_position_top > $(document).height() - view.top.height() && $(document).height() - view.top.height() > 0) {
new_position_top = $(document).height() - view.top.height();
}
//右限制
if (new_position_left > $(document).width() - view.top.width()) {
new_position_left = $(document).width() - view.top.width();
}
if (new_position_left < 0) {//左边的偏移量小于0的时候设置 左边的位置为0
new_position_left = 0;
}
view.top.css({
left: new_position_left + 'px',
top: new_position_top + 'px'
})
})
$(document).bind('mouseup', function (event) {
setting.cache.mouse_x = -1;
setting.cache.mouse_y = -1;
})
}
function msg(msg, color) {
let nda = new Date();
let t = nda.getHours() + ':' + nda.getMinutes() + ':' + nda.getSeconds();
msg = t + ' ' + msg;
$('#answer_log').append('+
(color || 'black') + '">' + msg + '');
}
//设置答案类型,0:未知,1:选择,2:非选择
function setAnswerType(type) {
setting.cache.type = type;
}
function appendAnswerView(answerText) {
if(/[\d]+?\./.test(answerText)){
answerText = answerText.replace((/[\d]+?\./), '').trim()
answerText = answerText.replace(/[\d]+?\)/, '').trim()
}
if (setting.cache.type == 1) {
if (setting.cache.count++ % 5 == 0) {
let start = Math.floor(setting.cache.count / 5) * 5 + 1;
$('
+ Math.floor(setting.cache.count / 5) + '">' + start
+ '. ' + answerText + '').appendTo(view.answerView);
} else {
let start = Math.floor(setting.cache.count / 5) * 5 + 1,
end = start + setting.cache.count % 5;
view.answerView.find('span[row="' + Math.floor(setting.cache.count / 5) + '"]').text(start + '-' + end + '. ');
$('' + answerText + '').appendTo(view.answerView);
}
} else {
$('' + (++setting.cache.count) + '. ' + answerText + '
').appendTo(view.answerView);
}
}
function clearAnswerView() {
view.answerView.empty();
setting.cache.count = 0;
setting.cache.type = 0;
}
function getscore() {
GM_xmlhttpRequest({
method: 'POST',
url: turl + 'getUserScore.php',
data: 'token=' + GM_getValue('utoken'),
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
},
onerror: (error) => {
//isQuestion = false;
swal("获取失败!网络或服务器错误,见常见问题Q9","warning");
//alert("获取失败!/n网络或服务器错误");
},
ontimeout: (error) => {
//isQuestion = false;
swal("获取失败!/n网络超时","warning");
//alert("获取答案失败!网络超时");
},
onload: function (xhr) {
GM_setValue('score', '')
setting.score = '';
document.querySelector('#score').value = '';
let rejson = JSON.parse(xhr.responseText);
console.log(rejson)
console.log("yz",rejson.code)
if(rejson.status != 0){
if(!GM_getValue('xtoken')){
//console.log('测试是否既然怒')
getxtoken();}
}else{
GM_setValue('score', rejson.score)
document.querySelector('#score').value = rejson.score;
return;
}
}
});
}
function conten_send_data(type, utoken, url, keyword, da, db, xtoken, testid) {
if (type == 'common') {
let contentJson = {};
contentJson.t = 'common';
contentJson.keyword = keyword;
contentJson.url = url;
contentJson.datas = da;
contentJson.utoken = utoken;
return encodeURIComponent(JSON.stringify(contentJson));
}
if (type == 'test') {
let contentJson = {};
contentJson.t = 'test';
contentJson.testid = testid;
contentJson.ua = da;
contentJson.ub = db;
contentJson.keyword = keyword;
contentJson.url = url;
contentJson.utoken = utoken;
contentJson.xtoken = xtoken;
return encodeURIComponent(JSON.stringify(contentJson));
}
return;
}
function setAnswerLink() {
$.each($("#tbody tr"), function (i, obj) {
//console.log("当前",obj.children[5].innerText);
if (obj.children[5].innerText.indexOf('未完成') != -1 || obj.children[5].innerText.indexOf('待批阅') != -1) {
let array = obj.children[6].children[0].onclick.toString().match(/'(.*?)'/g);
//console.log(array);
if (array.length == 3) {
let eid = array[0]
eid = eid.replace(/'/g, '')
let cid = array[1]
cid = cid.replace(/'/g, '')
let etype = array[2].match(/exerciseType\=([\s\S]*?)\&/g);
let keyword = obj.children[1].innerText;
let redata = {};
//swal("载入成功","{keyword}√载入完毕","error");
msg('
' + keyword + ' √载入完毕')
//conten_send_data(type, utoken, url, keyword, da, db, xtoken, testid)
let send_data = conten_send_data('test', setting.utoken, url, keyword, 'cid=' + cid + '#', 'exerciseId=' + eid + '&', GM_getValue('xtoken'), etype[0]);
console.log(send_data);
GM_setValue(eid, send_data)
}
}
})
}
/**
* 自动登入与去环境检测来源于Brush-JIM
* 已获得作者授权如果疑问反馈解决
* 作者主页:https://greasyfork.org/zh-CN/users/291772-brush-jim
**/
function autoLogin() {
// 自动登录功能
if (_self.location.href.indexOf('sso.unipus.cn/sso/login') != -1 && auto_login == 1) {
// 获取数据并赋值到 login_data ,如果没有则赋值 undefined
gm_get('login_data', undefined).then((login_data) => {
if (login_data === undefined) {
// 修改按钮
$("button[class='btn btn-login btn-fill']")[0].innerText = '自动登录\n(鼠标点击,不要回车)';
$("button[class='btn btn-login btn-fill']").on('click', function () {
$('input[name="rememberMe"]')[0].checked = false;
// 保存数据
gm_set('login_data', JSON.stringify({
'username': $("input[name='username']")[0].value,
'password': $("input[name='password']")[0].value
}));
})
} else {
let login_json = JSON.parse(login_data);
$("input[name='rememberMe']")[0].checked = false;
$("input[name='username']")[0].value = login_json.username;
$("input[name='password']")[0].value = login_json.password;
$("button[class='btn btn-login btn-fill']")[0].click();
}
})
}
// 重置登录信息功能 以及 去掉多余元素和弹窗
else if (_self.location.href.indexOf('u.unipus.cn/user/student') != -1) {
let Browser = myBrowser();
// 设置 sessionStorage,去掉环境检测
_self.sessionStorage.setItem("__env_tested__", Date());
// 设置 localStorage ,永久去掉环境检测
_self.localStorage.setItem("__env_tested__" + Browser, Browser);
// 修改 window.localStorage.getItem ,去掉版本说明及环境检测
_self.getItem_ = _self.localStorage.getItem;
_self.localStorage.getItem = function (a) {
if (a.search(/version_tested|env_tested/i) != -1) {
return true
} else {
return _self.getItem_(a);
}
}
// CSS去掉环境检测和版本说明的气泡
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '#env_newnotice,#version_newnotice {display: none!important;}'
document.getElementsByTagName('head').item(0).appendChild(style);
console.log(document.getElementsByTagName('head').item(0))
// 修改“退出”选项为“重新登录”,增加重置自动登录的选项
function Change_Menu() {
if ($("[class='menu-li']").length != 0) {
for (let a = 0; $('[class="menu-li"]').length > a; a++) {
if ($('[class="menu-li"]')[a].innerHTML == '退出') {
$('[class="menu-li"]')[a].innerHTML = '重新登录';
}
}
$("[class='hiden-menu']").append("