[Asm] 纯文本查看 复制代码
function getUrlParams(_key) {
var _array = location.href.split("?");
if (_array.length > 1) {
_array = _array[1].split("&");
for (var _i = 0; _i < _array.length; _i++) {
var _v = _array[_i].split("=");
if (_v.length > 1 && _key == _v[0]) {
return _v[1];
}
}
}
return null;
}
//获取课程列表
function getCourseList() {
$.ajax({
url: "https://ipx-api.yanxiu.com/task-center/course/queryCourseList?pageIndex=1&pageSize=100&projectId=" + getUrlParams("projectId") + "&toolId=" + getUrlParams("toolId") + "&roleKey=100&examineSubstanceRole=MEMBER&segmentId=9999&subjectId=9999",
type: "GET",
contentType: "application/json",
headers: {
"Accept": "application/json, text/plain, */*",
"Action-Type": "json",
"srxUserInfo": $.cookie("srxUserInfo"),
"X-DT-accessToken": $.cookie("X-DT-accessToken")
},
success: function (data) {
var _list = data.data.rows;
for (var _i = 0; _i < _list.length; _i++) {
var _o = _list[_i];
console.log(_o.completeTime + "/" + _o.totalDuration);
if (_o.completeTime <= _o.totalDuration) {
//window.sendMessage({ type: "closeOtherTabs" });
window.sendMessage({ type: "closeTabsFromKey", data: { keepKey: "list", closeKey: "detail?" } });
window.sendMessage({ type: "reloadTime", data: { time: 300 } });
window.sendMessage({ type: "createTab", data: { url: "https://ipx.yanxiu.com/grain/course/" + _o.id + "/detail?projectId=" + getUrlParams("projectId") + "&toolId=" + getUrlParams("toolId") + "&courseSourceId=" + _o.courseSourceId + "&role=100", selected: true } });
return;
}
}
}
});
}
function getCourseId() {
var _str = location.href.replace("https://ipx.yanxiu.com/grain/course/", "");
_str = _str.substr(0, _str.indexOf("/"));
return _str;
}
//给教授评星
function sendUserStar() {
var _d = {};
_d.userName = $(".login-name").text();
_d.courseId = getCourseId();
_d.toolId = getUrlParams("toolId");
_d.courseSourceId = getUrlParams("courseSourceId");
_d.rank = 5;
$.ajax({
url: "https://ipx-api.yanxiu.com/task-center/course/addUserCourseEvalution",
type: "POST",
contentType: "application/json",
data: JSON.stringify(_d),
dataType: "json",
headers: {
"Action-Type": "json",
"srxUserInfo": $.cookie("srxUserInfo"),
"X-DT-accessToken": $.cookie("X-DT-accessToken")
},
success: function (data) {
}
});
}
//获取用户信息
function getUserInfo() {
var _userId;
var _d = {};
$.ajax({
url: "https://ipx-api.yanxiu.com/train-project-center/user/getUserInfo",
type: "POST",
contentType: "application/json",
data: JSON.stringify(_d),
dataType: "json",
async: false,
headers: {
"Action-Type": "json",
"srxUserInfo": $.cookie("srxUserInfo"),
"X-DT-accessToken": $.cookie("X-DT-accessToken")
},
success: function (data) {
var _userName = data.data.userName;
_userId = data.data.userId;
}
});
return _userId;
}
//获取当前版块学习进度
function getCouresProgress() {
var _d = { "examineSubstance": "MEMBER", "classId": "", "examineSubstanceRole": "MEMBER", "toolId": getUrlParams("toolId"), "userId": getUserInfo(), "examineType": "tool", "projectId": getUrlParams("projectId") };
$.ajax({
url: "https://ipx-api.yanxiu.com/task-center/examine/result/tool/query",
type: "POST",
contentType: "application/json",
data: JSON.stringify(_d),
dataType: "json",
headers: {
"Action-Type": "json",
"srxUserInfo": $.cookie("srxUserInfo"),
"X-DT-accessToken": $.cookie("X-DT-accessToken")
},
success: function (data) {
console.log(JSON.stringify(data));
if (Number(data.data.totalFinishScore) < Number(data.data.totalRequireScore)) {
getCourseList();
} else {
console.log("视频已经完成");
window.sendMessage({ type: "reloadHome", data: { homeKey: "workspace?projectId", homeUrl: "https://ipx.yanxiu.com/train/workspace?projectId=5962355032887484498&role=100" } });
}
}
});
}
function getProgressById(_tid, _id) {
var _out = { finish: true };
$.ajax({
url: "https://ipx-api.yanxiu.com/task-center/tool/user/packTools?bizId1=" + _tid + "&bizId2=" + _id + "&bizSource=yxb&userRole=MEMBER",
type: "POST",
contentType: "application/json",
data: "{}",
dataType: "json",
async: false,
headers: {
"Action-Type": "json",
"srxUserInfo": $.cookie("srxUserInfo"),
"X-DT-accessToken": $.cookie("X-DT-accessToken")
},
success: function (data) {
//console.log(data);
var _o = data.data[0].toolExamines[0];
if (Number(_o.userScore) < Number(_o.totalScore)) {
_out.finish = false;
_out.id = _o.id;
}
}
});
return _out;
}
//获取本次培训的所有项目
function getMainList() {
console.log("获取课程目录");
$.ajax({
url: "https://ipx-api.yanxiu.com/train-project-center/projectPhase/personPage?trainProjectId=" + getUrlParams("projectId") + "&pageSize=10000&pageIndex=1",
type: "GET",
contentType: "application/json",
dataType: "json",
headers: {
"Action-Type": "json",
"srxUserInfo": $.cookie("srxUserInfo"),
"X-DT-accessToken": $.cookie("X-DT-accessToken")
},
success: function (data) {
//console.log(data);
var _list = data.data.rows;
for (var _i = 0; _i < _list.length; _i++) {
var _out = getProgressById(_list[_i].trainProjectId, _list[_i].id);
if (!_out.finish) {
var _url = "https://ipx.yanxiu.com/train/guide/course/list?projectId=" + _list[_i].trainProjectId + "&role=100&toolId=" + _out.id + "&stageId=" + _list[_i].id + "&barId=&examineSubstanceRole=MEMBER";
window.sendMessage({ type: "createTab", data: { url: _url, selected: true } });
return;
} else {
console.log(_list[_i].phaseName + " 视频已经学习完成!");
}
}
console.log("所有视频已经全部完成");
}
});
}
function autoClick() {
//视频播放完成,出现重新播放时
if ($(".replay").is(":visible")) {
window.sendMessage({ type: "reloadHome", data: { homeKey: "train/guide/course/list", homeUrl: "https://ipx.yanxiu.com/train/guide/course/list" } });
return;
}
//给教授点击星星时
if ($(".rate-item").length == 10) {
$(".rate-item").eq(9).hover();
$(".rate-item").eq(9).click();
$(".ivu-btn.ivu-btn-primary").eq(0).click();
return;
}
//出现点击继续计时的按钮时
if ($(".alarmClock-wrapper").is(":visible")) {
$(".alarmClock-wrapper").click();
}
}
function init() {
$.cookie = function (name, value, options) { if (typeof value != 'undefined') { options = options || {}; if (value === null) { value = ''; options.expires = -1 } var expires = ''; if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { var date; if (typeof options.expires == 'number') { date = new Date(); date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)) } else { date = options.expires } expires = '; expires=' + date.toUTCString() } var path = options.path ? '; path=' + options.path : ''; var domain = options.domain ? '; domain=' + options.domain : ''; var secure = options.secure ? '; secure' : ''; document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('') } else { var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = $.trim(cookies[i]); if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break } } } return cookieValue } };
//课程主页
if (location.href.indexOf("workspace?projectId") != -1) {
getMainList();
return;
}
//学习内容列表页
if (location.href.indexOf("course/list") != -1) {
getCouresProgress();
return;
}
//具体视频学习页
if (location.href.indexOf("detail?projectId") != -1) {
//给教授点击星星
sendUserStar();
setInterval(autoClick, 1000);
return;
}
}
if (typeof $ == "undefined") {
var s = document.createElement('script');
s.onload = init;
s.src = 'https://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js';
document.getElementsByTagName('HEAD')[0].appendChild(s);
} else {
init();
}