// ==UserScript==
// @name 视频学习助手
// @namespace http://tampermonkey.net/
// @version 3.5.6
// @description 支持:乌鲁木齐建设职业培训中心、山东开放大学、师学通国培计划、山东省文化和旅游厅继续教育公共服务平台、甘肃省公务员网络培训网、山东省教师教育网、广东人才继续教育网、四平农村成人高等专科学校、继续教育学习平台、兰州大学、安徽继续教育在线、江西省补贴性线上职业培训、贵州继续教育网、河南专技培训、泰安市专业技术人员、河南省地矿系统专业技术、自贡开放大学、河南新闻出版学校、天水博通职业技术培训学校、兰州资源环境职业技术大学、国家智慧教育公共服务平台、北京教师学习网、甘肃庆阳、兰州文理学院继续教育、浙江省住房和城乡建设行业专业技术人员继续教育系统、学习图强、优学院、福建师范继续教育、河南新闻出版学校、漯河远程教育、河南省专业技术人员学习公社、梦想在线、专技天下、广西住房城乡建设行业专业人员、兰州理工大学、广东远程职业培训平台、全国文化和旅游市场在线培训系统、贵州省专业技术人员继续教育平台。
// @author
// @match *://*/*
// @grant GM_xmlhttpRequest
// @grant GM_openInTab
// @grant GM_setValue
// @grant GM_getValue
// @grant window.close
// @antifeature payment
// @noframes
// @icon https://www.zhihuishu.com/favicon.ico
// @connect www.gaozhiwang.top
// @connect localhost
// @license MIT
// @downloadURL none
// ==/UserScript==
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
(function () {
let basehost = 'http://www.gaozhiwang.top';
let bserUrl = 'http://www.gaozhiwang.top:7001';
const panelcss = `
.myTool{
background: #fff;
width: 234px;
font-size: 14px;
display: flex;
flex-direction: column;
align-items: center;
position: fixed;
z-index: 999;
top: 70px;
left: 44px;
box-sizing: border-box;
padding: 15px 9px;
border-radius: 5px;
box-shadow: 0 0 9px rgba(0,0,0,.5);
}
.controls{
position: absolute;
right: 12px;
font-size: 27px;
top: 9px;
cursor: pointer;
transition: all 0.4s;
}
.controls:hover{
color: #1f74c;
transform: rotate(360deg);
}
.myTool-content{
transition: all 0.4s;
overflow: hidden;
}
.mytoolkeyipt{
width: 130px;
height: 22px !important;
outline: none;
padding: 0px 3px;
border: 1px solid #757575FF;
border-radius: 3px;
font-size: 13px;
padding: 0px 3px;
margin-right: 5px;
margin-top: 2px;
}
.addkey-btn{
color: #fff;
background: #1f74ca;
}
.removkey-btn{
color: #000;
display: none;
background: #eee;
}
.handleKeyBtn{
width: 54px;
height: 24px;
margin-top: 2px;
border: none;
font-size: 12px;
border-radius: 2px;
cursor: pointer;
}
.handleSpeedUp{
background: orange;
font-size: 12px;
color: #fff;
padding: 4px 15px;
border-radius: 5px;
margin: 0 auto;
max-width: 80px;
margin-top: 10px;
cursor: pointer;
text-align: center;
}
.ctxTipWrap{
min-width: 200px;
min-height: 50px;
text-align: center;
line-height: 50px;
background: #fff;
position: fixed;
z-index: 999;
left: 50%;
top: 50%;
border-radius: 9px;
box-shadow: 0 0 5px rgba(0,0,0,.6);
display:none;
}
.cxtsection{
width: 100%;
box-sizing: border-box;
padding: 0 5px;
margin-bottom: 2px;
}
.cxtsection .ctx-title{
text-align: left;
margin-top: 12px;
font-size: 12px;
color: #4e5969;
border-left: 2px solid #1f74ca;
border-radius: 2px;
padding-left: 3px;
line-height: 16px;
}
.ctxsection2{
display: flex;
justify-content: space-between;
}
.ctxsection2 .speed-select{
width: 50%;
height: 22px !important;
outline: none;
position: relative;
top: 10px;
border: 1px solid #757575FF;
border-radius: 3px;
padding-left: 10px;
}
.ctxsection3{
display: flex;
align-items: center;
justify-content: space-between;
}
.feedbackBtn{
font-size: 13px;
position: relative;
top: 5px;
cursor: pointer;
color: #000;
}
a{
text-decoration: none;
}
`;
const panelhtml = `
`;
let ElementObj = {};
let Internetcourse = {
gongxiligong: { id: 44, name: '广理工在线', host: 'www.kepeiol.com' },
};
let speedArr = [1, 3, 5, 10, 16];
let toolOption = {
accelerator: 1,
CtxMain: null,
SchoolType: -1
};
class Main {
constructor() {
this.studentType = 1;
this.speedStatus = 0;
this.listenVidoeStatusTimer = null;
this.init();
}
init() {
setTimeout(() => {
let _schoolInfoColletion = localStorage.getItem('schoolInfoColletion');
if (_schoolInfoColletion) {
}
else {
this.colletionSchoolData();
}
}, 2500);
}
updateSpeedElement(num) {
if (this.speedStatus == 0)
return;
ElementObj.$video.playbackRate = num;
}
handleClickSpeedUp(callback) {
return __awaiter(this, void 0, void 0, function* () {
let key = localStorage.getItem('mytoolkey');
if (key) {
this.speedStatus = 1;
let result = yield fetchData({
method: 'GET',
url: bserUrl + `/speedup?toolkey=${key}&canuse=${toolOption.SchoolType}`,
});
if (result.code == 200) {
this.speedStatus = 1;
toolOption.CtxMain.play();
}
else {
showTip(`🔉🔉🔉${result.message}`, 5000, true);
return;
}
this.randomListen();
}
else if (!key) {
alert('请先购买key');
window.open(basehost);
}
else {
alert('程序错误,请联系客服');
}
});
}
handleAddKey(callback) {
return __awaiter(this, void 0, void 0, function* () {
if (!ElementObj.$ipt.value) {
window.open(basehost);
return;
}
let result = yield fetchData({
method: 'GET',
url: bserUrl + '/vertifykey?toolkey=' + ElementObj.$ipt.value
});
if (result.data.count > 0) {
localStorage.setItem('mytoolkey', ElementObj.$ipt.value);
localStorage.setItem('_localSpeed', toolOption.accelerator.toString());
callback(ElementObj.$ipt.value);
}
else {
alert('输入的key不存在');
}
});
}
handleRemoveKey() {
localStorage.removeItem('mytoolkey');
localStorage.removeItem('_localSpeed');
ElementObj.$title3.innerText = '绑定key:';
ElementObj.$mytoolkey.style.display = 'none';
ElementObj.$ctxsection2.style.display = 'none';
ElementObj.$nokey.style.display = 'block';
ElementObj.$ipt.style.display = 'block';
ElementObj.$addKey.style.display = 'block';
ElementObj.$removeKey.style.display = 'none';
ElementObj.$handleSpeedUp.style.background = 'orange';
ElementObj.$handleSpeedUp.innerText = '点击加速';
this.updateSpeedElement(1);
}
stopSpeedUp() {
this.speedStatus = 0;
toolOption.CtxMain.updateSpeedElement(1);
ElementObj.$handleSpeedUp.style.background = 'orange';
ElementObj.$handleSpeedUp.innerText = '点击加速';
showTip(`🔉停止加速成功`);
}
handleChangeCtxSpeed(e) {
let key = localStorage.getItem('mytoolkey');
if (key) {
let whiteList = speedArr;
let s = Number(e);
if (e && whiteList.includes(s)) {
toolOption.accelerator = s;
localStorage.setItem('_localSpeed', s.toString());
if (ElementObj.$video) {
ElementObj.$video.playbackRate = s;
}
}
}
else if (!key) {
alert('请先购买key');
window.open(basehost);
}
else {
alert('程序错误,请联系客服');
}
}
colletionSchoolData() {
return __awaiter(this, void 0, void 0, function* () {
let key = `s${toolOption.SchoolType}`;
let result = yield fetchData({
method: 'GET',
url: bserUrl + '/colletionschool?schoolType=' + key,
});
if (result.code == 200) {
localStorage.setItem('schoolInfoColletion', `${new Date()}`);
}
});
}
randomListen() {
}
listenVidoeStatus($video, callback) {
if (!$video)
return;
let count = 0;
this.listenVidoeStatusTimer = setInterval(() => {
if ($video.readyState < 4) {
console.log(`检测到${count}次,视频正在加载`);
count += 1;
if (count >= 20) {
location.reload();
}
}
let status = $video.paused;
if (status) {
count += 1;
console.log(`检测到视频暂停了${count}次`);
if (typeof callback == 'function') {
if (count >= 20) {
location.reload();
}
else {
callback();
}
}
else {
console.log('callback不是一个函数');
}
}
}, 3000);
}
changeHtml($wrap) {
return __awaiter(this, void 0, void 0, function* () {
let _style = `
width: 100%;
height: 100%;
background: #eae9e9;
position: absolute;
z-index: 999;
overflow: scroll;
top: 0;
padding-left: 10px;
`;
let dom = document.createElement('div');
dom.setAttribute('class', 'ctxstatsbox');
dom.setAttribute('style', _style);
$wrap.appendChild(dom);
yield sleep(300);
ElementObj.$ctxstatsbox = document.querySelector('.ctxstatsbox');
this.addInfo('🔉初始化已完成,正在播放');
});
}
addInfo(str, type) {
let $ctxstatsbox_lis = document.querySelectorAll('.ctxstatsbox_li');
if ($ctxstatsbox_lis.length >= 15) {
ElementObj.$ctxstatsbox.innerHTML = '';
}
let li = `${str}`;
ElementObj.$ctxstatsbox.innerHTML += li;
}
listenPageHide() {
let timer3;
document.addEventListener("visibilitychange", () => {
if (document.hidden) {
console.log("页面被隐藏");
let count = 0;
timer3 = setInterval(() => {
count += 1;
if (count >= 5) {
this.addInfo('⚠️⚠️⚠️请勿长时间隐藏该学习页面', 0);
}
}, 5000);
}
else {
clearInterval(timer3);
console.log("页面被显示");
}
});
}
}
class gongxiligong extends Main {
constructor() {
super();
this.taskLength = 0;
this.parentIndex = -1;
this.currentIndex = -1;
this.videoplaying = -1;
this.timer = null;
this._init();
}
_init() {
return __awaiter(this, void 0, void 0, function* () {
let $open = $el('.p-down-open');
$open === null || $open === void 0 ? void 0 : $open.click();
let interval = setInterval(() => __awaiter(this, void 0, void 0, function* () {
console.log('寻找中。。。');
ElementObj.$allTask = document.querySelectorAll('.courseVideoItem');
if (ElementObj.$allTask.length) {
clearInterval(interval);
this.getCurrentIndex();
return;
}
let $video = document.querySelector('video');
if (!!$video) {
clearInterval(interval);
this.handleClickSpeedUp();
}
}), 1000);
});
}
getCurrentIndex() {
return __awaiter(this, void 0, void 0, function* () {
ElementObj.$allTask.forEach((item, index) => {
let $antprogresstext = item.querySelector('.ant-progress-text');
let status = $antprogresstext.innerText;
if (parseInt(status) < 98 && this.currentIndex == -1) {
this.currentIndex = index;
}
});
let $nextBtn = ElementObj.$allTask[this.currentIndex].querySelector('.courseVideoItem-button');
yield sleep(200);
$nextBtn.click();
setTimeout(() => {
location.reload();
}, 4500);
console.log('this.currentIndex==>>>', this.currentIndex);
});
}
getVideoDom() {
return new Promise(resolve => {
let Timer = setInterval(() => {
ElementObj.$video = document.querySelector('video');
if (!!ElementObj.$video) {
clearInterval(Timer);
resolve(true);
}
}, 1000);
});
}
play() {
return __awaiter(this, void 0, void 0, function* () {
clearInterval(this.listenVidoeStatusTimer);
clearInterval(this.timer);
clearInterval(this.timer2);
yield this.getVideoDom();
ElementObj.$video.volume = 0;
ElementObj.$video.play();
ElementObj.$video.playbackRate = toolOption.accelerator;
this.changeHtml($el('.video-react-controls-enabled'));
this.listenPageHide();
this.listenStudyTime();
this.listenVidoeStatus(ElementObj.$video, () => {
ElementObj.$video.volume = 0;
ElementObj.$video.play();
});
ElementObj.$video.addEventListener('ended', () => {
console.log('ended===>>>');
this.playNext();
});
});
}
listenStudyTime(type) {
showTip('🔉课件正在学习,请务点击或长时间隐藏');
let count = 0;
this.timer2 = setInterval(() => {
count += 1;
if (type == 0) {
this.addInfo(`已监测${count}次,当前状态正在学习`);
}
else {
let duration = (ElementObj.$video.duration / 60).toFixed(2);
let time = (ElementObj.$video.currentTime / 60).toFixed(2);
this.addInfo(`已监测${count}次,当前状态正在学习,已播放${time}分钟,视频总共时长为${duration}分钟`);
}
}, 5000);
}
playNext() {
return __awaiter(this, void 0, void 0, function* () {
yield sleep(2500);
let $nextBtn = document.querySelector('.navigation-button-text');
$nextBtn.click();
setTimeout(() => {
location.reload();
}, 4500);
});
}
}
class Addpanel {
constructor() {
this.$panelWrap = document.createElement('div');
this.$panelStyle = document.createElement('style');
this._init();
}
_init() {
var _b, _c, _d, _e, _f, _g;
this.$panelWrap.innerHTML = panelhtml;
this.$panelStyle.innerHTML = panelcss;
(_b = document.querySelector('head')) === null || _b === void 0 ? void 0 : _b.appendChild(this.$panelStyle);
if (toolOption.SchoolType == 3) {
(_c = document.querySelector('#bigContainer')) === null || _c === void 0 ? void 0 : _c.appendChild(this.$panelWrap);
}
else if (toolOption.SchoolType == 7) {
(_d = document.querySelector('.layout-content')) === null || _d === void 0 ? void 0 : _d.appendChild(this.$panelWrap);
}
else if (toolOption.SchoolType == 11) {
(_e = document.querySelector('.task-dashboard-page')) === null || _e === void 0 ? void 0 : _e.appendChild(this.$panelWrap);
}
else if (toolOption.SchoolType == 18) {
(_f = document.querySelector('.screen_wide_1')) === null || _f === void 0 ? void 0 : _f.appendChild(this.$panelWrap);
}
else {
(_g = document.querySelector('body')) === null || _g === void 0 ? void 0 : _g.appendChild(this.$panelWrap);
}
ElementObj.$title3 = document.querySelector('.title3');
ElementObj.$mytoolkey = document.querySelector('.mytoolkey');
ElementObj.$nokey = document.querySelector('.nokey');
ElementObj.$addKey = document.getElementById('addKey');
ElementObj.$removeKey = document.getElementById('removeKey');
ElementObj.$ipt = document.querySelector('.mytoolkeyipt');
ElementObj.$handleSpeedUp = document.querySelector('.handleSpeedUp');
ElementObj.$playButton = document.querySelector('#playButton');
ElementObj.$ctxTipWrap = document.querySelector('#ctxTipWrap');
ElementObj.$ctxsection2 = document.querySelector('.ctxsection2');
ElementObj.$ctxcontrols = document.querySelector('.ctxcontrols');
let storageKey = localStorage.getItem('mytoolkey');
if (storageKey) {
this.handleSetHtml(storageKey);
}
this.optimizePannel();
this.setSpeedOption();
this.addEvent();
this.getSlogan();
}
optimizePannel() {
}
setSpeedOption() {
ElementObj.$speedSelect = document.querySelector('#ctxspeed');
let html = ``;
for (var i = 0; i < speedArr.length; i++) {
let str = `
`;
html += str;
}
ElementObj.$speedSelect.innerHTML = html;
var _localSpeed = localStorage.getItem('_localSpeed');
if (_localSpeed) {
ElementObj.$speedSelect.value = _localSpeed;
toolOption.accelerator = Number(_localSpeed);
}
}
handleSetHtml(key) {
try {
ElementObj.$ipt.style.display = 'none';
ElementObj.$title3.innerText = '当前key:';
ElementObj.$mytoolkey.innerText = key;
ElementObj.$mytoolkey.style.display = 'block';
ElementObj.$nokey.style.display = 'none';
ElementObj.$removeKey.style.display = 'block';
ElementObj.$addKey.style.display = 'none';
ElementObj.userKey = key;
}
catch (e) {
}
}
addEvent() {
ElementObj.$addKey.addEventListener('click', () => {
toolOption.CtxMain.handleAddKey((key) => {
this.handleSetHtml(key);
});
});
ElementObj.$removeKey.addEventListener('click', () => {
toolOption.CtxMain.handleRemoveKey();
});
ElementObj.$handleSpeedUp.addEventListener('click', () => {
toolOption.CtxMain.handleClickSpeedUp();
});
ElementObj.$ctxsection2.addEventListener('change', (e) => {
toolOption.CtxMain.handleChangeCtxSpeed(e.target.value);
});
ElementObj.$ctxcontrols.addEventListener('click', () => {
let $myToolContent = document.querySelector('.myTool-content');
let isHide = GM_getValue("hideCtx", null);
if (isHide) {
$myToolContent.style.height = 'auto';
ElementObj.$ctxcontrols.innerText = '×';
}
else {
$myToolContent.style.height = '0px';
ElementObj.$ctxcontrols.innerText = '🔛';
}
GM_setValue("hideCtx", !isHide);
});
}
getSlogan() {
fetchData({
url: bserUrl + '/getslogan',
method: "GET"
}).then((res) => {
ElementObj.$slogan = document.querySelector('#slogan');
ElementObj.$slogan.innerHTML = res.result.text1;
});
}
}
function $el(selector, root2 = window.document) {
const el2 = root2.querySelector(selector);
return el2 === null ? void 0 : el2;
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function fetchData(option) {
return new Promise(resolve => {
try {
GM_xmlhttpRequest(Object.assign(Object.assign({}, option), { onload: function (xhr) {
if (xhr.status == 200) {
resolve(JSON.parse(xhr.response));
}
} }));
}
catch (e) {
fetch(option.url, {
method: option.method
}).then(res => res.json()).then(res => {
resolve(res);
});
}
});
}
function showTip(text, time = 1500, isAlert) {
ElementObj.$ctxTipWrap.style.display = 'block';
ElementObj.$ctxTipWrap.innerText = text;
let timer = setTimeout(() => {
ElementObj.$ctxTipWrap.style.display = 'none';
}, time);
if (isAlert) {
alert(text);
}
}
function recognitionType() {
let current_host = location.host;
toolOption.CtxMain = gongxiligong;
toolOption.SchoolType = Internetcourse.gongxiligong.id;
}
function hack() {
var _a;
const vue = (_a = $el(".video-study")) == null ? void 0 : _a.__vue__;
const empty = () => {
};
vue.checkout = empty;
vue.notTrustScript = empty;
vue.checkoutNotTrustScript = empty;
const _videoClick = vue.videoClick;
vue.videoClick = function (...args) {
const e = new PointerEvent("click");
const event = Object.create({ isTrusted: true });
Object.setPrototypeOf(event, e);
args[args.length - 1] = event;
return _videoClick.apply(vue, args);
};
vue.videoClick = function (...args) {
args[args.length - 1] = { isTrusted: true };
return _videoClick.apply(vue, args);
};
}
setTimeout(() => {
recognitionType();
toolOption.CtxMain = new toolOption.CtxMain();
new Addpanel();
}, 5000);
})();