教师研修网-骨干教师提升培训自动切课插件
骨干教师提升培就只有服务器计时的视频,客户端只能老老实实观看,看完一个课程它不能自动切换,所以整个插件,让它一次完成所有视频观看任务
function getUrlParams(_key) {
var _array = location.href.split("?");
if (_array.length > 1) {
_array = _array.split("&");
for (var _i = 0; _i < _array.length; _i++) {
var _v = _array.split("=");
if (_v.length > 1 && _key == _v) {
return _v;
}
}
}
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;
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.toolExamines;
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.trainProjectId, _list.id);
if (!_out.finish) {
var _url = "https://ipx.yanxiu.com/train/guide/course/list?projectId=" + _list.trainProjectId + "&role=100&toolId=" + _out.id + "&stageId=" + _list.id + "&barId=&examineSubstanceRole=MEMBER";
window.sendMessage({ type: "createTab", data: { url: _url, selected: true } });
return;
} else {
console.log(_list.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 = .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); 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').appendChild(s);
} else {
init();
}
Pwaerm 发表于 2021-11-29 09:09
这是打包好的,解压后得到一个.CRX文件
拖放到Chromium 内核 的任意浏览器中(我用的360极速浏览 ...
这样才对新人很友好,评分也会高呀 要给新人说一下放哪里用啊 lsll 发表于 2021-11-29 08:52
老大,要给新人说一下放哪里用啊
这是打包好的,解压后得到一个.CRX文件
拖放到Chromium 内核 的任意浏览器中(我用的360极速浏览器),就添加好这个插件了。
然后打开学习网站,它就会自动完成视频学习。 本帖最后由 byh3025 于 2021-11-29 06:56 编辑
谢谢分享,现在这种国培计划越来越多了,你的这个可以放油猴里吗? 国培都成一种形式了 老大,要给新人说一下放哪里用啊:lol byh3025 发表于 2021-11-29 06:55
谢谢分享,现在这种国培计划越来越多了,你的这个可以放油猴里吗?
我没有用油猴,理论上可以的 。
javascript:var s=document.createElement('script');s.onload=function(){};s.src='http://127.0.0.1/temp.js?r='+Math.random();document.getElementsByTagName('body').appendChild(s);
我通常使用的是浏览器收藏夹注入 请楼主更新一下 这个可真是个好东西啊,收藏一下,嘿嘿 本帖最后由 Juaran 于 2023-3-8 10:36 编辑
感谢分享