// ==UserScript==
// @name 联通党校-刷课程,可秒刷
// @namespace https://gitee.com/zouyongs/js-liantongdangxiao
// @version 1.30
// @description 联通党校刷课程视频.注意,只能在主题专栏中,选择某一专栏并进入后才能正确使用,进入后未正常生效请刷新页面。不懂请查阅附加信息。本次更新:使用说明已内置。
// @author ZouYs
// @match https://m.campus.chinaunicom.cn/*
// @icon https://m.campus.chinaunicom.cn/favicon.ico
// @require https://cdn.jsdelivr.net/npm/[email protected]/bin/jsencrypt.min.js
// @grant unsafeWindow
// ==/UserScript==
(function () {
'use strict';
var helpHTMLSting=`<div style="width: 600px; height: 400px; overflow: auto;">
<h1 style="color: red;text-align: center;font-weight: bold;font-size: 30px;">刷课-使用说明</h1>
<div>
<h3 style="font-weight: bold;font-size: 24px;">在哪里使用?</h3>
<text>选择主题专栏,进入某一专区内,即页面中间有欢迎某某某的界面便可成功使用。</text>
</div>
<div>
<h3 style="font-weight: bold;font-size: 24px;">如何使用?</h3>
<text style="color: red;">注意:手动更换页码或专栏ID后,需要点击更新课程</text><br>
<text style="color: red;">注意:每点一次开始,只能刷展示框列出的课程,刷完本页后,需手动更新页码,点击更新课程后,在点击开始</text><br>
<h4 style="font-weight: bold;font-size: 18px;">控件解析</h4>
<text>可手动输入专栏ID,在点击更新课程可刷其他专栏课程;<br>
睡眠时间:每完成一个课程暂停时间,建议不小于1s;<br>
当前页:为本页面的页码,通常第一页的页课程数最多有8个,第二页修改页课程数就可成功;<br>
页课程数:为本页面展示的课程数量,即本次所刷的课程数量,在展示框中展示,点击一次开始,所刷课程数===页内课程数;<br>
专栏总课程数:为此专栏中所有的课程总数,不用管;
</text>
<h4 style="font-weight: bold;font-size: 18px;">按钮解析</h4>
<text>开始按钮:待提示信息变绿后,点击开始即开始刷展示框中的课程,本次所刷的课程数量=页课程数,若要刷其他的,需手动更改页码;<br>
更新课程按钮:可更新展示框中的课程信息,在每次刷完后,需手动更新页码(也可增加页课程数,这样一次可多刷点),后点击更新课程,待展示框课程更新后可再次点击开始;<br>
一键完成周任务课程按钮:点击即可自动完成我的学习中的每周任务。<br>
</text>
</div>
</div>`
//悬浮展示窗
window.onload = function () {
let show = 0
let showWindow = document.createElement('button')
showWindow.style.width = '60px'
showWindow.style.height = '40px'
showWindow.innerText = '开刷!'
showWindow.style.position = 'fixed'
showWindow.style.left = '0px'
showWindow.style.top = '150px'
showWindow.style.zIndex = '111'
showWindow.addEventListener('click', fuc_show)
function fuc_show() {
// let is_show=document.querySelector('#myWindow')
show++
if (show == 1) {
myWindow.style.display = 'block'
}
else {
show = 0
myWindow.style.display = 'none'
}
}
document.body.appendChild(showWindow)
let myWindow = document.createElement('div')
myWindow.id = 'mywin'
myWindow.style.width = '300px'
myWindow.style.height = '400px'
myWindow.style.backgroundColor = '#efefef'
myWindow.style.position = 'fixed'
myWindow.style.left = '50px'
myWindow.style.top = '150px'
myWindow.style.zIndex = '111'
myWindow.style.display = 'none'
document.body.appendChild(myWindow)
var matchUrl="https://m.campus.chinaunicom.cn/#/web/ind_ThemeCourses?id="
if(window.location.href.includes(matchUrl))
{
myWindow.innerHTML = `<button id="btn-begin">开始</button>
<button id="btn-update">更新课程</button>
睡眠时间:<input id="sleeptime" value="1" style="display: inline-block;width: 40px;"> 秒
<br>专栏ID:<div id="c-id" contenteditable="true" style="display: inline-block;width: 60px;">
${window.location.href.split('?')[1].split('=')[1]}</div><button id="btn-week">一键完成周任务课程</button><br>
当前页:<input id="c-cur" type="number" min="1" step="1" value="1" style="display: inline-block;width: 40px;">
页课程数:<input id="c-size" type="number" min="8" step="1" value="8" style="display: inline-block;width: 40px;">
<br>专栏总课程数:<div id="c-total" style="display: inline-block;width: 20px;color: #f5083f;">36</div>
<button id="btn-help" style="color:red;margin-left:10px;">点击获取帮助</button>
</div><div style="width:90%;margin: auto auto;border-radius: 10px;position: relative;border: 1px solid grey;height: 200px;margin-top: 0px;">
<ul id="ul" style=" overflow-x: auto;white-space: nowrap;margin:0px 0px 0px 0px; overflow: auto;height:100%;">
<li>1</li>
</ul>
当前进度:
<div id="myProgress" style="width: 0%; height: 20px; background-color: green; position: relative; bottom: 0;">
</div>
<div id="progrssNum" style="display: flex;justify-content: center;position: relative; top: -20px;">0%</div>
<div id="waitInfo" style="color:red;display: flex;justify-content: center">正在获取课程树信息中,请稍等....</div>
</div>`
}
else
{
myWindow.style.left = '60px'
myWindow.style.top = '130px'
myWindow.style.width = '600px'
myWindow.style.height = '400px'
myWindow.innerHTML =helpHTMLSting
return
}
//提示信息窗口
let helpWindow = document.createElement('div')
helpWindow.id='floating-window'
helpWindow.style.width='600px'
helpWindow.style.height='400px'
helpWindow.style.position='fixed'
helpWindow.style.top='130px'
helpWindow.style.left='400px'
helpWindow.style.border= '1px solid #ccc'
helpWindow.style.background='#f7f7f7'
helpWindow.style.cursor='move'
helpWindow.style.display = 'none';
helpWindow.innerHTML=helpHTMLSting
document.body.appendChild(helpWindow)
var floatingWindow = document.getElementById('floating-window');
var isDragging = false;
var offsetX, offsetY;
var showHelp=false
floatingWindow.addEventListener('mousedown', function(e) {
isDragging = true;
offsetX = e.clientX - floatingWindow.getBoundingClientRect().left;
offsetY = e.clientY - floatingWindow.getBoundingClientRect().top;
});
document.addEventListener('mousemove', function(e) {
if (isDragging) {
floatingWindow.style.left = (e.clientX - offsetX) + 'px';
floatingWindow.style.top = (e.clientY - offsetY) + 'px';
}
});
document.addEventListener('mouseup', function() {
isDragging = false;
});
document.addEventListener('click', function(e) {
if (showHelp && !floatingWindow.contains(e.target) ) {
floatingWindow.style.display = 'none';
showHelp=false
}
});
document.getElementById('btn-help').addEventListener('click', function(e) {
e.stopPropagation()//防止继续冒泡
showHelp=true
floatingWindow.style.display = 'block';
});
//随机参数
function randomStrFuc() {
for (var n = 32, t = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"], e = "", c = 0; c < n; c++) {
var u = parseInt(61 * Math.random() + "");
e += t[u]
}
return e
}
//md5加密
var ERROR = "input is invalid type", WINDOW = "object" == typeof window, root = WINDOW ? window : {}, WEB_WORKER = (root.JS_MD5_NO_WINDOW && (WINDOW = !1),
!WINDOW && "object" == typeof self), NODE_JS = !root.JS_MD5_NO_NODE_JS && "object" == typeof process && process.versions && process.versions.node, COMMON_JS = (NODE_JS ? root = global : WEB_WORKER && (root = self),
!root.JS_MD5_NO_COMMON_JS && "object" == typeof module && module.exports), ARRAY_BUFFER = !root.JS_MD5_NO_ARRAY_BUFFER && "undefined" != typeof ArrayBuffer, HEX_CHARS = "0123456789abcdef".split(""), EXTRA = [128, 32768, 8388608, -2147483648], SHIFT = [0, 8, 16, 24], OUTPUT_TYPES = ["hex", "array", "digest", "buffer", "arrayBuffer", "base64"], BASE64_ENCODE_CHAR = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""), blocks = [], buffer8, buffer, buffer8, blocks, createOutputMethod = (ARRAY_BUFFER && (buffer = new ArrayBuffer(68),
buffer8 = new Uint8Array(buffer),
blocks = new Uint32Array(buffer)),
!root.JS_MD5_NO_NODE_JS && Array.isArray || (Array.isArray = function (t) {
return "[object Array]" === Object.prototype.toString.call(t)
}
),
!ARRAY_BUFFER || !root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW && ArrayBuffer.isView || (ArrayBuffer.isView = function (t) {
return "object" == typeof t && t.buffer && t.buffer.constructor === ArrayBuffer
}
))
//进度条
var myProgress=document.getElementById('myProgress')
var myProgressNum=document.getElementById('progrssNum')
//防刁民
var readyCheck=false
function Md5(t) {
t ? (blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0,
this.blocks = blocks,
this.buffer8 = buffer8) : ARRAY_BUFFER ? (t = new ArrayBuffer(68),
this.buffer8 = new Uint8Array(t),
this.blocks = new Uint32Array(t)) : this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = this.hBytes = 0,
this.finalized = this.hashed = !1,
this.first = !0
}
Md5.prototype.update = function (t) {
if (!this.finalized) {
var e, n = typeof t;
if ("string" != n) {
if ("object" != n)
throw ERROR;
if (null === t)
throw ERROR;
if (ARRAY_BUFFER && t.constructor === ArrayBuffer)
t = new Uint8Array(t);
else if (!(Array.isArray(t) || ARRAY_BUFFER && ArrayBuffer.isView(t)))
throw ERROR;
e = !0
}
for (var i, r, o = 0, a = t.length, s = this.blocks, l = this.buffer8; o < a;) {
if (this.hashed && (this.hashed = !1,
s[0] = s[16],
s[16] = s[1] = s[2] = s[3] = s[4] = s[5] = s[6] = s[7] = s[8] = s[9] = s[10] = s[11] = s[12] = s[13] = s[14] = s[15] = 0),
e)
if (ARRAY_BUFFER)
for (r = this.start; o < a && r < 64; ++o)
l[r++] = t[o];
else
for (r = this.start; o < a && r < 64; ++o)
s[r >> 2] |= t[o] << SHIFT[3 & r++];
else if (ARRAY_BUFFER)
for (r = this.start; o < a && r < 64; ++o)
(i = t.charCodeAt(o)) < 128 ? l[r++] = i : (i < 2048 ? l[r++] = 192 | i >> 6 : (i < 55296 || 57344 <= i ? l[r++] = 224 | i >> 12 : (i = 65536 + ((1023 & i) << 10 | 1023 & t.charCodeAt(++o)),
l[r++] = 240 | i >> 18,
l[r++] = 128 | i >> 12 & 63),
l[r++] = 128 | i >> 6 & 63),
l[r++] = 128 | 63 & i);
else
for (r = this.start; o < a && r < 64; ++o)
(i = t.charCodeAt(o)) < 128 ? s[r >> 2] |= i << SHIFT[3 & r++] : (i < 2048 ? s[r >> 2] |= (192 | i >> 6) << SHIFT[3 & r++] : (i < 55296 || 57344 <= i ? s[r >> 2] |= (224 | i >> 12) << SHIFT[3 & r++] : (i = 65536 + ((1023 & i) << 10 | 1023 & t.charCodeAt(++o)),
s[r >> 2] |= (240 | i >> 18) << SHIFT[3 & r++],
s[r >> 2] |= (128 | i >> 12 & 63) << SHIFT[3 & r++]),
s[r >> 2] |= (128 | i >> 6 & 63) << SHIFT[3 & r++]),
s[r >> 2] |= (128 | 63 & i) << SHIFT[3 & r++]);
this.lastByteIndex = r,
this.bytes += r - this.start,
64 <= r ? (this.start = r - 64,
this.hash(),
this.hashed = !0) : this.start = r
}
return 4294967295 < this.bytes && (this.hBytes += this.bytes / 4294967296 << 0,
this.bytes = this.bytes % 4294967296),
this
}
}
Md5.prototype.finalize = function () {
var t, e;
this.finalized || (this.finalized = !0,
(t = this.blocks)[(e = this.lastByteIndex) >> 2] |= EXTRA[3 & e],
56 <= e && (this.hashed || this.hash(),
t[0] = t[16],
t[16] = t[1] = t[2] = t[3] = t[4] = t[5] = t[6] = t[7] = t[8] = t[9] = t[10] = t[11] = t[12] = t[13] = t[14] = t[15] = 0),
t[14] = this.bytes << 3,
t[15] = this.hBytes << 3 | this.bytes >>> 29,
this.hash())
}
,
Md5.prototype.hash = function () {
var t, e, n, i, r, o = this.blocks, a = this.first ? ((a = ((t = ((t = o[0] - 680876937) << 7 | t >>> 25) - 271733879 << 0) ^ (e = ((e = (-271733879 ^ (n = ((n = (-1732584194 ^ 2004318071 & t) + o[1] - 117830708) << 12 | n >>> 20) + t << 0) & (-271733879 ^ t)) + o[2] - 1126478375) << 17 | e >>> 15) + n << 0) & (n ^ t)) + o[3] - 1316259209) << 22 | a >>> 10) + e << 0 : (t = this.h0,
a = this.h1,
e = this.h2,
((a += ((t = ((t += ((n = this.h3) ^ a & (e ^ n)) + o[0] - 680876936) << 7 | t >>> 25) + a << 0) ^ (e = ((e += (a ^ (n = ((n += (e ^ t & (a ^ e)) + o[1] - 389564586) << 12 | n >>> 20) + t << 0) & (t ^ a)) + o[2] + 606105819) << 17 | e >>> 15) + n << 0) & (n ^ t)) + o[3] - 1044525330) << 22 | a >>> 10) + e << 0);
a = ((a += ((t = ((t += (n ^ a & (e ^ n)) + o[4] - 176418897) << 7 | t >>> 25) + a << 0) ^ (e = ((e += (a ^ (n = ((n += (e ^ t & (a ^ e)) + o[5] + 1200080426) << 12 | n >>> 20) + t << 0) & (t ^ a)) + o[6] - 1473231341) << 17 | e >>> 15) + n << 0) & (n ^ t)) + o[7] - 45705983) << 22 | a >>> 10) + e << 0,
a = ((a += ((t = ((t += (n ^ a & (e ^ n)) + o[8] + 1770035416) << 7 | t >>> 25) + a << 0) ^ (e = ((e += (a ^ (n = ((n += (e ^ t & (a ^ e)) + o[9] - 1958414417) << 12 | n >>> 20) + t << 0) & (t ^ a)) + o[10] - 42063) << 17 | e >>> 15) + n << 0) & (n ^ t)) + o[11] - 1990404162) << 22 | a >>> 10) + e << 0,
a = ((a += ((t = ((t += (n ^ a & (e ^ n)) + o[12] + 1804603682) << 7 | t >>> 25) + a << 0) ^ (e = ((e += (a ^ (n = ((n += (e ^ t & (a ^ e)) + o[13] - 40341101) << 12 | n >>> 20) + t << 0) & (t ^ a)) + o[14] - 1502002290) << 17 | e >>> 15) + n << 0) & (n ^ t)) + o[15] + 1236535329) << 22 | a >>> 10) + e << 0,
a = ((a += ((n = ((n += (a ^ e & ((t = ((t += (e ^ n & (a ^ e)) + o[1] - 165796510) << 5 | t >>> 27) + a << 0) ^ a)) + o[6] - 1069501632) << 9 | n >>> 23) + t << 0) ^ t & ((e = ((e += (t ^ a & (n ^ t)) + o[11] + 643717713) << 14 | e >>> 18) + n << 0) ^ n)) + o[0] - 373897302) << 20 | a >>> 12) + e << 0,
a = ((a += ((n = ((n += (a ^ e & ((t = ((t += (e ^ n & (a ^ e)) + o[5] - 701558691) << 5 | t >>> 27) + a << 0) ^ a)) + o[10] + 38016083) << 9 | n >>> 23) + t << 0) ^ t & ((e = ((e += (t ^ a & (n ^ t)) + o[15] - 660478335) << 14 | e >>> 18) + n << 0) ^ n)) + o[4] - 405537848) << 20 | a >>> 12) + e << 0,
a = ((a += ((n = ((n += (a ^ e & ((t = ((t += (e ^ n & (a ^ e)) + o[9] + 568446438) << 5 | t >>> 27) + a << 0) ^ a)) + o[14] - 1019803690) << 9 | n >>> 23) + t << 0) ^ t & ((e = ((e += (t ^ a & (n ^ t)) + o[3] - 187363961) << 14 | e >>> 18) + n << 0) ^ n)) + o[8] + 1163531501) << 20 | a >>> 12) + e << 0,
a = ((a += ((n = ((n += (a ^ e & ((t = ((t += (e ^ n & (a ^ e)) + o[13] - 1444681467) << 5 | t >>> 27) + a << 0) ^ a)) + o[2] - 51403784) << 9 | n >>> 23) + t << 0) ^ t & ((e = ((e += (t ^ a & (n ^ t)) + o[7] + 1735328473) << 14 | e >>> 18) + n << 0) ^ n)) + o[12] - 1926607734) << 20 | a >>> 12) + e << 0,
a = ((a += ((r = (n = ((n += ((i = a ^ e) ^ (t = ((t += (i ^ n) + o[5] - 378558) << 4 | t >>> 28) + a << 0)) + o[8] - 2022574463) << 11 | n >>> 21) + t << 0) ^ t) ^ (e = ((e += (r ^ a) + o[11] + 1839030562) << 16 | e >>> 16) + n << 0)) + o[14] - 35309556) << 23 | a >>> 9) + e << 0,
a = ((a += ((r = (n = ((n += ((i = a ^ e) ^ (t = ((t += (i ^ n) + o[1] - 1530992060) << 4 | t >>> 28) + a << 0)) + o[4] + 1272893353) << 11 | n >>> 21) + t << 0) ^ t) ^ (e = ((e += (r ^ a) + o[7] - 155497632) << 16 | e >>> 16) + n << 0)) + o[10] - 1094730640) << 23 | a >>> 9) + e << 0,
a = ((a += ((r = (n = ((n += ((i = a ^ e) ^ (t = ((t += (i ^ n) + o[13] + 681279174) << 4 | t >>> 28) + a << 0)) + o[0] - 358537222) << 11 | n >>> 21) + t << 0) ^ t) ^ (e = ((e += (r ^ a) + o[3] - 722521979) << 16 | e >>> 16) + n << 0)) + o[6] + 76029189) << 23 | a >>> 9) + e << 0,
a = ((a += ((r = (n = ((n += ((i = a ^ e) ^ (t = ((t += (i ^ n) + o[9] - 640364487) << 4 | t >>> 28) + a << 0)) + o[12] - 421815835) << 11 | n >>> 21) + t << 0) ^ t) ^ (e = ((e += (r ^ a) + o[15] + 530742520) << 16 | e >>> 16) + n << 0)) + o[2] - 995338651) << 23 | a >>> 9) + e << 0,
a = ((a += ((n = ((n += (a ^ ((t = ((t += (e ^ (a | ~n)) + o[0] - 198630844) << 6 | t >>> 26) + a << 0) | ~e)) + o[7] + 1126891415) << 10 | n >>> 22) + t << 0) ^ ((e = ((e += (t ^ (n | ~a)) + o[14] - 1416354905) << 15 | e >>> 17) + n << 0) | ~t)) + o[5] - 57434055) << 21 | a >>> 11) + e << 0,
a = ((a += ((n = ((n += (a ^ ((t = ((t += (e ^ (a | ~n)) + o[12] + 1700485571) << 6 | t >>> 26) + a << 0) | ~e)) + o[3] - 1894986606) << 10 | n >>> 22) + t << 0) ^ ((e = ((e += (t ^ (n | ~a)) + o[10] - 1051523) << 15 | e >>> 17) + n << 0) | ~t)) + o[1] - 2054922799) << 21 | a >>> 11) + e << 0,
a = ((a += ((n = ((n += (a ^ ((t = ((t += (e ^ (a | ~n)) + o[8] + 1873313359) << 6 | t >>> 26) + a << 0) | ~e)) + o[15] - 30611744) << 10 | n >>> 22) + t << 0) ^ ((e = ((e += (t ^ (n | ~a)) + o[6] - 1560198380) << 15 | e >>> 17) + n << 0) | ~t)) + o[13] + 1309151649) << 21 | a >>> 11) + e << 0,
a = ((a += ((n = ((n += (a ^ ((t = ((t += (e ^ (a | ~n)) + o[4] - 145523070) << 6 | t >>> 26) + a << 0) | ~e)) + o[11] - 1120210379) << 10 | n >>> 22) + t << 0) ^ ((e = ((e += (t ^ (n | ~a)) + o[2] + 718787259) << 15 | e >>> 17) + n << 0) | ~t)) + o[9] - 343485551) << 21 | a >>> 11) + e << 0,
this.first ? (this.h0 = t + 1732584193 << 0,
this.h1 = a - 271733879 << 0,
this.h2 = e - 1732584194 << 0,
this.h3 = n + 271733878 << 0,
this.first = !1) : (this.h0 = this.h0 + t << 0,
this.h1 = this.h1 + a << 0,
this.h2 = this.h2 + e << 0,
this.h3 = this.h3 + n << 0)
}
,
Md5.prototype.hex = function () {
this.finalize();
var t = this.h0
, e = this.h1
, n = this.h2
, i = this.h3;
return HEX_CHARS[t >> 4 & 15] + HEX_CHARS[15 & t] + HEX_CHARS[t >> 12 & 15] + HEX_CHARS[t >> 8 & 15] + HEX_CHARS[t >> 20 & 15] + HEX_CHARS[t >> 16 & 15] + HEX_CHARS[t >> 28 & 15] + HEX_CHARS[t >> 24 & 15] + HEX_CHARS[e >> 4 & 15] + HEX_CHARS[15 & e] + HEX_CHARS[e >> 12 & 15] + HEX_CHARS[e >> 8 & 15] + HEX_CHARS[e >> 20 & 15] + HEX_CHARS[e >> 16 & 15] + HEX_CHARS[e >> 28 & 15] + HEX_CHARS[e >> 24 & 15] + HEX_CHARS[n >> 4 & 15] + HEX_CHARS[15 & n] + HEX_CHARS[n >> 12 & 15] + HEX_CHARS[n >> 8 & 15] + HEX_CHARS[n >> 20 & 15] + HEX_CHARS[n >> 16 & 15] + HEX_CHARS[n >> 28 & 15] + HEX_CHARS[n >> 24 & 15] + HEX_CHARS[i >> 4 & 15] + HEX_CHARS[15 & i] + HEX_CHARS[i >> 12 & 15] + HEX_CHARS[i >> 8 & 15] + HEX_CHARS[i >> 20 & 15] + HEX_CHARS[i >> 16 & 15] + HEX_CHARS[i >> 28 & 15] + HEX_CHARS[i >> 24 & 15]
}
let cur_url = window.location.href.split('?')
var id_cour = cur_url[1].split('=')[1];
// let cur_url = window.location.href.split('?')
// var id = cur_url[1];
// var token = document.cookie.split('token=')[1].split(';')[0]
// var timestamp=Math.floor(Date.now() / 1000);
// var companyId=window.localStorage.getItem("companyId") || 0
// var organizationId=window.localStorage.getItem("organizationId") || 0
// var from='WEB'
// var randomStr= randomStrFuc()
var publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAooxomrujIP9vcxxNmS+Q1xxnaoxAfluwFvDR3+G+p84QMsePXDD67cLjJ+7n+79u2xoG7fVvDnzHDW+X5D/0/Dv9ajUaBpFQl3jqKwRiP3Lrx08seYzWIWDGHEjurbZrWGHRJNdoM7tEQPdPZftZC6iOm7kSjDIDiuqaIh9g3hqFSVQ5r15Dvae6qtREo1nDWKsf3tH6nkvVD2pIh3TBJUoGdfbPqnw/tNvzhwOX9tg7NjhZ8Yet1ctVt297G5HCwPSIBjhUKEtLYLk/8scPrzXnQpAU05m5WnHfDhfvvG2xoVXckveNvZhv6lvxTZqRkUBOI1pU16U9Tz4aDpCU7QIDAQAB";
//加密参数并序列化、字符串化参数
//返回对象,包含字符串参数和sign
/**
* 最重要的地方,破解sign参数
* @param {*} e
* @param {*} smp
* @returns
*/
//加密参数,返回包装数据,便于在接口中直接调用
function encryptData(e,smp=true) {
var t, c = "",
r = Object.keys(e).sort();
for (t in r) {
var o = e[r[t]];
null != o && (c += r[t] + "=" + o + "&")
}
if(smp){
console.log("字符串参数: " + c)
}
var key_md5 = new Md5(!0).update(c)['hex']()
if(smp){
console.log("key_md5: " + key_md5)
}
return { 'serString': c, 'sign': encrypt(key_md5,smp) }
}
//加密,获得sign
function encrypt(key,smp=true) {
var rsa = new JSEncrypt();
rsa.setPublicKey(publicKey);
var encryptedData = rsa.encrypt(key);
if(smp){
console.log("sign: " + encryptedData);
}
return encryptedData
}
//接口用参数
var e = {
token: document.cookie.split('token=')[1].split(';')[0],
timestamp: Math.floor(Date.now() / 1000),
companyId: window.localStorage.getItem("companyId") || 0,
from: "WEB",
organizationId: window.localStorage.getItem("organizationId") || 0,
randomStr: randomStrFuc(),
id: document.getElementById('c-id').innerText,
subjectId: "",
status: 1,
name: '',
currentPage: document.getElementById("c-cur").value,
pageSize: document.getElementById("c-size").value,
total: 0
}
//接口列表
var url = {
courseList: 'https://app.campus.chinaunicom.cn/app/themeColumn/getMyAreaInfoCourse',
courseInfo: 'https://app.campus.chinaunicom.cn/app/course/info',
studyCourse: 'https://app.campus.chinaunicom.cn/app/course/playtimeV2',
weekCourse:'https://app.campus.chinaunicom.cn/app/weekTask/list'
}
//每周任务
var weekData={
token: document.cookie.split('token=')[1].split(';')[0],
timestamp: Math.floor(Date.now() / 1000),
companyId: window.localStorage.getItem("companyId") || 0,
from: "WEB",
organizationId: window.localStorage.getItem("organizationId") || 0,
randomStr: randomStrFuc()
}
var cList = []//展示框课程
var allCount//待刷课程树总数,用于进度条展示
cList = getData(url, e).then(v => {
cList = v
statistics().then(v=>{
readyCheck=true
allCount=v
console.log('allCount:'+v)
console.log('课程树信息已获取完毕~')
document.getElementById('waitInfo').innerText=`课程树信息已获取~可以开始`
document.getElementById('waitInfo').style.color='green'
})
})
var btn_begin=document.getElementById('btn-begin')
var waitInfo=document.getElementById('waitInfo')
btn_begin.addEventListener('click', () => {
console.log('cList=' + cList)
if(readyCheck===true)
{
readyCheck=false
btn_begin.innerText='已开始'
waitInfo.innerText=`正在修改课程学习时间中....`
waitInfo.style.color='yellow'
begin(cList,allCount).then(v=>{
btn_begin.innerText='开始'
readyCheck=true
waitInfo.innerText=`本次修改已完成!`
waitInfo.style.color='green'
})
}
else {
switch(Math.floor(Math.random() * 10)){
case 0:
case 1:
case 2:
case 3:
case 4:
alert('请等待信息获取完成~~')
break;
default:
alert('呆,刁民!')
}
}
})
var btn_week=document.getElementById('btn-week')
var weekTaskCheck=true
btn_week.addEventListener('click',()=>{
if(readyCheck===true && weekTaskCheck)
{
readyCheck=false
btn_week.innerText='正在完成周任务'
waitInfo.innerText=`正在完成周任务....`
waitInfo.style.color='yellow'
getInfoWeek().then(v=>{
begin(v.weekList,v.count).then(v=>{
weekTaskCheck=false
btn_week.innerText='周任务已完成'
readyCheck=true
waitInfo.innerText=`本次修改已完成!`
waitInfo.style.color='green'
})
})
}
else {
if(!weekTaskCheck){
alert('周任务已经完成!')
}
else
{
switch(Math.floor(Math.random() * 10)){
case 0:
case 1:
case 2:
case 3:
case 4:
alert('请等待信息获取完成~~')
break;
default:
alert('呆,刁民!')
}
}
}
})
var btn_update=document.getElementById('btn-update')
btn_update.addEventListener('click', () => {
if(readyCheck===true){
readyCheck=false
btn_update.innerText='正在更新'
waitInfo.innerText=`正在获取课程信息中....`
waitInfo.style.color='red'
update(e).then(v=>{
btn_update.innerText='更新课程'
readyCheck=true
waitInfo.innerText=`课程信息已获取~`
waitInfo.style.color='green'
})
}
else{
switch(Math.floor(Math.random() * 10)){
case 0:
case 1:
case 2:
case 3:
case 4:
alert('请等待信息获取完成~~')
break;
default:
alert('呆,刁民!')
}
}
})
/**
* @description: 统计信息,获取总数,用于进度条
* @return {*}
*/
async function statistics(){
let count=0
for (let ll of cList){
await getCourseInfo(ll.id,false).then(v => {
ll.child=v
count+=v.length
})
}
return count
}
/**
* @description: 获取周任务信息
* @return {*}
*/
async function getInfoWeek(){
const res=await request(url.weekCourse,encryptData(weekData))
const resData=await res.json()
let count=0
for (let ll of resData.entity.weekTaskList){
await getCourseInfo(ll.courseId,false).then(v => {
ll.child=v
//使用原来的begin函数,则需要改变id值为课程ID,因为原来对象中的id为专栏ID
ll.id=ll.courseId
count+=v.length
})
}
return {weekList:resData.entity.weekTaskList,count:count}
}
/**
* @description: 开始按钮事件处理函数
* @return {*}
*/
async function begin(list,aCount) {
// console.log('开始专栏ID:' + window.location.href.split('?')[1].split('=')[1])
// console.log(typeof(cList))
myProgress.style.width=`0%`
myProgressNum.innerText=`0%`
let llList=0
for (let ll of list) {
let courseId = ll.id
// await sleep(document.getElementById("sleeptime").value * 1000)
for (let kk of ll.child) {
llList++
kk.courseId = courseId
console.log('正在修改学习时间kpointId:' + kk.kpointId + "")
await sleep(document.getElementById("sleeptime").value * 1000)
await studyCourse(kk).then( v => {
console.log('本次结果:' + v.message)
let pgr=Math.round((llList)/aCount *100)
console.log('pgr:'+pgr)
myProgress.style.width=`${pgr}%`
myProgressNum.innerText=`${pgr}%`
})
}
}
}
/**
* @description: 更新按钮事件处理函数
* @return {*}
*/
async function update(e) {
myProgress.style.width=`0%`
myProgressNum.innerText=`0%`
document.getElementById('waitInfo').style.color='red'
document.getElementById('waitInfo').innerText=`正在获取课程树信息中,请稍等....`
e.id = document.getElementById('c-id').innerText
e.currentPage = document.getElementById("c-cur").value
e.pageSize = document.getElementById("c-size").value
await getData(url, e).then( async v => {
cList = v
await statistics().then(v=>{
allCount=0
allCount=v
console.log('allCount:'+v)
console.log('课程树信息已获取完毕~')
document.getElementById('waitInfo').innerText=`课程树信息已获取~可以开始`
document.getElementById('waitInfo').style.color='green'
})
})
}
/**
* @description: 获取当前专栏课程信息,并展示的展示框
* @param {*} time
* @return {*}
*/
async function getData(url, e) {
try {
const response = await request(url.courseList, encryptData(e));
const courseList = await response.json();
console.log(courseList.entity.courseList); // 打印获取的数据
// 更新窗口数据
document.getElementById('c-total').innerText = courseList.entity.page.totalResultSize;
let li = '';
for (let ii of courseList.entity.courseList) {
li += `<li style="margin-bottom:5px;height: 20px;width: 100%;">已看:${(ii.playTime / ii.totalPlayTime * 100).toFixed(2)}% ${ii.name} id: ${ii.id} </li>`;
}
document.getElementById('ul').innerHTML = li;
console.log('窗口数据已更新');
return courseList.entity.courseList; // 返回获取的数据
} catch (error) {
console.error(error);
throw error; // 处理异常情况
}
}
async function sleep(time) {
console.log('睡眠' + time / 1000 + 's')
return await new Promise((resolve) => setTimeout(resolve, time));
}
//
/**
* @description: 获取单个课程信息
* @param {*} id
* @return {*}
*/
async function getCourseInfo(id,smp=true) {
var signleCourse = {
token: document.cookie.split('token=')[1].split(';')[0],
timestamp: Math.floor(Date.now() / 1000),
companyId: window.localStorage.getItem("companyId") || 0,
from: "WEB",
organizationId: window.localStorage.getItem("organizationId") || 0,
randomStr: randomStrFuc(),
courseId: id
}
var courseInfo
//发送请求
const response = await request(url.courseInfo, encryptData(signleCourse,smp),smp)
const data = await response.json()
if(smp){
console.log(data.entity.courseNode); // 这里打印获取的数据
}
courseInfo = data.entity.courseNode
return courseInfo
}
//更改课程学习时间
async function studyCourse(courseNode) {
var study = {
token: document.cookie.split('token=')[1].split(';')[0],
timestamp: Math.floor(Date.now() / 1000),
companyId: window.localStorage.getItem("companyId") || 0,
from: "WEB",
organizationId: window.localStorage.getItem("organizationId") || 0,
randomStr: randomStrFuc(),
type: "playback",
kpointId: 36864,
courseId: 26120,
breakpoint: 331,
studyTime: 480,
}
study.studyTime = courseNode.courseMinutes * 60 + courseNode.courseSeconds
study.kpointId = courseNode.kpointId
study.courseId = courseNode.courseId
study.breakpoint = study.studyTime
const response = await request(url.studyCourse, encryptData(study))
const data = await response.json()
return data
}
//发送fetchPOST请求
//返回data
/**
* @description:
* @param {*} url
* @param {*} e
* @return {*}
*/
async function request(url, e,smp=true) {
if(smp){
console.log('正在发送请求->url:' + url)
}
return fetch(url + "?" + e.serString + "sign=" + e.sign, {
"headers": {
"accept": "application/json, text/plain, */*",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
"content-type": "application/x-www-form-urlencoded",
"sec-ch-ua": "\"Microsoft Edge\";v=\"117\", \"Not;A=Brand\";v=\"8\", \"Chromium\";v=\"117\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site"
},
"referrer": "https://m.campus.chinaunicom.cn/",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": "",
"method": "POST",
"mode": "cors",
"credentials": "omit"
})
}
}
})();