Skip to content

Instantly share code, notes, and snippets.

@1208nn
Last active July 11, 2023 14:29
Show Gist options
  • Save 1208nn/c39d88ffca57d3a602f6aa740ba978b1 to your computer and use it in GitHub Desktop.
Save 1208nn/c39d88ffca57d3a602f6aa740ba978b1 to your computer and use it in GitHub Desktop.
乐课网助手:用于快速完成乐课网录播课学习任务,仅限学习交流,后果一概不负责

乐课网助手

用于快速完成乐课网录播课学习任务

安装

  1. 桌面设备或Android手机可以安装用户脚本管理器Tampermonkey篡改猴或其他插件如油猴
  2. iOS 可以使用via Userscripts for Safari gear Alook等支持用户脚本的Browsers或插件
  3. Android 可以使用via等支持用户脚本的Browsers
  4. 更多支持的程序可以在Greasy Fork查看,同时也提供安装教程
  5. 由于一些限制,暂时没有Greasy Fork上发布
  6. 使用控制台无需安装
  7. 安装此用户脚本 (此版本仅使用于桌面设备)
  8. 同时适用于桌面设备移动设备的版本支持自动提交,无需手动操作,播放页面加载完成后等待2秒即可
  9. 调速脚本 (仅推荐脚本,并非原作者)

使用方法

选择用户脚本管理器右键菜单中快速完成课程选项即可

或者在播放界面打开开发人员工具>控制台复制并粘贴下面的链接内的内容(也适用于移动设备)

leke.helper.console.js

声明

  • 仅限学习交流,后果一概不负责

更新计划

  • 3.0 在课程目录批量操作
// ==UserScript==
// @name 乐课网助手Auto
// @version 2.0.1fix1
// @author 1208nn
// @namespace https://gist.github.com/1208nn/c39d88ffca57d3a602f6aa740ba978b1
// @updateURL https://gist.github.com/1208nn/c39d88ffca57d3a602f6aa740ba978b1/raw/leke.helper.auto.user.js
// @downloadURL https://gist.github.com/1208nn/c39d88ffca57d3a602f6aa740ba978b1/raw/leke.helper.auto.user.js
// @description 用于乐课网录播课学习任务,仅限学习交流,后果一概不负责
// @match https://www.letaoedu.com/page/lt/weike/play?*
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addStyle
// @run-at document-end
// @connect https://file.leke.cn/*
// @connect https://www.letaoedu.com/*
// ==/UserScript==
(async function () {
'use strict';
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
await delay(1000);
const urlParams = new URLSearchParams(window.location.search);
const courseID = parseInt(urlParams.get('courseId'));
const cwId = urlParams.get('stuCwid');
const gcId = urlParams.get('stuCid');
function getMilliseconds() {
const durationElement = document.querySelector('.duration');
const durationText = durationElement.textContent;
const [minutes, seconds] = durationText.split(':');
const durationInMillis = (parseInt(minutes) * 60 + parseInt(seconds)) * 1000;
return durationInMillis;
}
const Duration = getMilliseconds();
const reportTime = Date.now();
const userId = INITSTATE.userInfo.userId;
const userName = INITSTATE.userInfo.userName;
const requestData1 = {
courseId: courseID,
courseType: 2,
watchId: cwId,
watchPosition: Duration,
reportTime: reportTime
};
const requestData2 = {
cwId: cwId,
duration: Duration,
userId: userId
};
class FetchRequests {
constructor(URL, method, data) {
this.URL = URL;
this.method = method;
this.data = data;
this.headers = {
'Content-Type': 'application/json'
};
this.struct = {
method: this.method,
headers: this.headers
}
if (this.data) {
this.struct.body = JSON.stringify(this.data);
}
fetch(this.URL, this.struct);
}
}
const requests = [
['https://www.letaoedu.com/proxy/lesson/auth/common/watch/report.htm', requestData1],
['https://www.letaoedu.com/proxy/resource/auth/cware/common/saveStudyTime.htm', requestData2]
];
await Promise.all(requests.map(request => new FetchRequests(request[0], 'POST', request[1])));
const requestData = {
"cwId": cwId,
"userName": userName,
"duration": Duration,
"rightRate": 100,
"isComplete": 100,
"frameNumber": 0,
"answerRecord": "",
"userId": userId,
"gcId": gcId
};
fetch('https://www.letaoedu.com/proxy/resource/auth/cware/common/saveStudyAnswerRecordV2.htm', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(requestData)
});
})();
/*---------------
用于控制台手动输入
---------------*/
const urlParams = new URLSearchParams(window.location.search);
const courseID = parseInt(urlParams.get('courseId'));
const cwId = urlParams.get('stuCwid');
const gcId = urlParams.get('stuCid');
function getMilliseconds() {
const durationElement = document.querySelector('.duration');
const durationText = durationElement.textContent;
const [minutes, seconds] = durationText.split(':');
const durationInMillis = (parseInt(minutes) * 60 + parseInt(seconds)) * 1000;
return durationInMillis;
}
const Duration = getMilliseconds();
const reportTime = Date.now();
const userId = INITSTATE.userInfo.userId;
const userName = INITSTATE.userInfo.userName;
const requestData1 = {
courseId: courseID,
courseType: 2,
watchId: cwId,
watchPosition: Duration,
reportTime: reportTime
};
const requestData2 = {
cwId: cwId,
duration: Duration,
userId: userId
};
class FetchRequests {
constructor(URL, method, data) {
this.URL = URL;
this.method = method;
this.data = data;
this.headers = {
'Content-Type': 'application/json'
};
this.struct = {
method: this.method,
headers: this.headers
}
if (this.data) {
this.struct.body = JSON.stringify(this.data);
}
fetch(this.URL, this.struct);
}
}
const requests = [
['https://www.letaoedu.com/proxy/lesson/auth/common/watch/report.htm', requestData1],
['https://www.letaoedu.com/proxy/resource/auth/cware/common/saveStudyTime.htm', requestData2]
];
await Promise.all(requests.map(request => new FetchRequests(request[0], 'POST', request[1])));
const requestData = {
"cwId": cwId,
"userName": userName,
"duration": Duration,
"rightRate": 100,
"isComplete": 100,
"frameNumber": 0,
"answerRecord": "",
"userId": userId,
"gcId": gcId
};
fetch('https://www.letaoedu.com/proxy/resource/auth/cware/common/saveStudyAnswerRecordV2.htm', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(requestData)
});
// ==UserScript==
// @name 乐课网助手
// @version 2.0.1
// @author 1208nn
// @namespace https://gist.github.com/1208nn/c39d88ffca57d3a602f6aa740ba978b1
// @updateURL https://gist.github.com/1208nn/c39d88ffca57d3a602f6aa740ba978b1/raw/leke.helper.user.js
// @downloadURL https://gist.github.com/1208nn/c39d88ffca57d3a602f6aa740ba978b1/raw/leke.helper.user.js
// @description 用于乐课网录播课学习任务,选择用户脚本管理器右键菜单中快速完成课程选项即可,仅限学习交流,后果一概不负责,计划3.0可在课程目录批量操作,后期随时可能加入错误检测报告功能,日志提示功能,成功后提示功能
// @match https://www.letaoedu.com/page/lt/weike/play?*
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addStyle
// @run-at document-start
// @connect https://file.leke.cn/*
// @connect https://www.letaoedu.com/*
// ==/UserScript==
(function () {
'use strict';
const urlParams = new URLSearchParams(window.location.search);
const courseID = parseInt(urlParams.get('courseId'));
const cwId = urlParams.get('stuCwid');
const gcId = urlParams.get('stuCid');
GM_registerMenuCommand('快速完成课程', async function () {
function getMilliseconds() {
const durationElement = document.querySelector('.duration');
const durationText = durationElement.textContent;
const [minutes, seconds] = durationText.split(':');
const durationInMillis = (parseInt(minutes) * 60 + parseInt(seconds)) * 1000;
return durationInMillis;
}
const Duration = getMilliseconds();
const reportTime = Date.now();
const userId = INITSTATE.userInfo.userId;
const userName = INITSTATE.userInfo.userName;
const requestData1 = {
courseId: courseID,
courseType: 2,
watchId: cwId,
watchPosition: Duration,
reportTime: reportTime
};
const requestData2 = {
cwId: cwId,
duration: Duration,
userId: userId
};
class FetchRequests {
constructor(URL, method, data) {
this.URL = URL;
this.method = method;
this.data = data;
this.headers = {
'Content-Type': 'application/json'
};
this.struct = {
method: this.method,
headers: this.headers
}
if (this.data) {
this.struct.body = JSON.stringify(this.data);
}
fetch(this.URL, this.struct);
}
}
const requests = [
['https://www.letaoedu.com/proxy/lesson/auth/common/watch/report.htm', requestData1],
['https://www.letaoedu.com/proxy/resource/auth/cware/common/saveStudyTime.htm', requestData2]
];
await Promise.all(requests.map(request => new FetchRequests(request[0], 'POST', request[1])));
const requestData = {
"cwId": cwId,
"userName": userName,
"duration": Duration,
"rightRate": 100,
"isComplete": 100,
"frameNumber": 0,
"answerRecord": "",
"userId": userId,
"gcId": gcId
};
fetch('https://www.letaoedu.com/proxy/resource/auth/cware/common/saveStudyAnswerRecordV2.htm', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(requestData)
})
});
GM_registerMenuCommand('视频下载', async function () {
console.log('视频下载');
var fileId, filePath;
await fetch(`https://www.letaoedu.com/proxy/beike/auth/common/microcourse/new/preview.htm?microcourseId=${INITSTATE.mcId}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => {
console.log(data.datas.data.fileId);
fileId = data.datas.data.fileId;
})
console.log(fileId);
await fetch(`https://www.letaoedu.com/auth/global/fs/file/access/data.htm?id=${fileId}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => {
console.log(data.datas.file.path);
filePath = data.datas.file.path;
})
console.log(filePath);
window.location.href = filePath;
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment