Skip to content

Commit

Permalink
Update to 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
chettoy committed Oct 1, 2023
1 parent e9fb752 commit 5b0409b
Show file tree
Hide file tree
Showing 13 changed files with 2,595 additions and 2,260 deletions.
6 changes: 4 additions & 2 deletions build/cxmooc-tools/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "网课小工具(remastered)",
"version": "3.0.0",
"version": "3.1.0",
"description": "一个 大学生网课 学习工具,Edge,谷歌,油猴支持.全自动任务,视频倍速秒过,作业考试题库(੧ᐛ੭挂科模式,启动)",
"icons": {
"16": "img/logo.png",
Expand All @@ -21,7 +21,9 @@
{
"matches": [
"*://*/mycourse/studentstudy?*",
"*://*/mooc-ans/mycourse/studentstudy?*",
"*://*/work/doHomeWorkNew?*",
"*://*/mooc-ans/mooc2/work/dowork?*",
"*://*/work/selectWorkQuestionYiPiYue?*",
"*://*/exam/test/reVersionTestStartNew?*",
"*://*/exam-ans/exam/test/reVersionTestStartNew*",
Expand Down Expand Up @@ -85,7 +87,7 @@
"use_dynamic_url": false
}
],
"homepage_url": "https://err.pw/cxmooc-tools/?v=3.0.0b2",
"homepage_url": "https://err.pw/cxmooc-tools/?v=3.1.0",
"content_security_policy": {
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self';"
}
Expand Down
4,715 changes: 2,496 additions & 2,219 deletions package-lock.json

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cxmooc-tools",
"version": "3.0.0",
"version": "3.1.0",
"description": "一个 大学生网课 学习工具, 衍生版本 (੧ᐛ੭挂科模式,启动)",
"main": "mooc.js",
"scripts": {
Expand All @@ -25,30 +25,30 @@
},
"homepage": "https://github.com/chettoy/cxmooc-tools#readme",
"devDependencies": {
"@types/chrome": "^0.0.235",
"@types/gh-pages": "^3.2.1",
"@types/jest": "^29.5.1",
"@types/node-telegram-bot-api": "^0.61.6",
"@vuepress/plugin-back-to-top": "^2.0.0-beta.61",
"@vuepress/plugin-google-analytics": "^2.0.0-beta.61",
"@types/chrome": "^0.0.246",
"@types/gh-pages": "^3.2.2",
"@types/jest": "^29.5.5",
"@types/node-telegram-bot-api": "^0.61.8",
"@vuepress/plugin-back-to-top": "^2.0.0-beta.67",
"@vuepress/plugin-google-analytics": "^2.0.0-beta.67",
"@wasm-tool/wasm-pack-plugin": "^1.7.0",
"crx": "^5.0.1",
"css-loader": "^6.7.3",
"gh-pages": "^5.0.0",
"html-webpack-plugin": "^5.5.1",
"jest": "^29.5.0",
"node-fetch": "^3.3.1",
"node-telegram-bot-api": "^0.61.0",
"style-loader": "^3.3.2",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.2",
"typescript": "^5.0.4",
"vue-loader": "^17.1.0",
"css-loader": "^6.8.1",
"gh-pages": "^6.0.0",
"html-webpack-plugin": "^5.5.3",
"jest": "^29.7.0",
"node-fetch": "^3.3.2",
"node-telegram-bot-api": "^0.63.0",
"style-loader": "^3.3.3",
"ts-jest": "^29.1.1",
"ts-loader": "^9.4.4",
"typescript": "^5.2.2",
"vue-loader": "^17.2.2",
"vue-template-compiler": "^2.7.14",
"vuepress": "^2.0.0-beta.61",
"webpack": "^5.82.1",
"webpack-cli": "^5.1.1",
"webpack-merge": "^5.8.0"
"vuepress": "^2.0.0-beta.67",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-merge": "^5.9.0"
},
"dependencies": {
"js-base64": "^3.7.5",
Expand Down
9 changes: 6 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@ interface PlatformConfig {
}

export class SystemConfig {
public static version = 3.0;
public static version = 3.1;
public static url = "https://cx.icodef.com/";
public static hotVersion = "3.0.0";
public static hotVersion = "3.1.0";
//TODO:优化规则,可以通过ci自动生成匹配规则到tampermonkey和manifest文件中
public static match: { [key: string]: Array<string> } = {
"cx": [
"*://*/mycourse/studentstudy?*",
"*://*/mooc-ans/mycourse/studentstudy?*",
"*://*/work/doHomeWorkNew?*",
"*://*/mooc-ans/mooc2/work/dowork?*",
"*://*/work/selectWorkQuestionYiPiYue?*",
"*://*/exam/test/reVersionTestStartNew?*",
"*://*/exam-ans/exam/test/reVersionTestStartNew*",
"*://*/ztnodedetailcontroller/visitnodedetail?*",
"*://*/antispiderShowVerify.ac*",
"*://*/html/processVerify.ac?*",
Expand Down Expand Up @@ -54,7 +57,7 @@ export class SystemConfig {
description: "进入一个页面就会自动开始挂机,完成一个任务之后会自动进行下一个",
type: "checkbox",
key: "auto",
value: true,
value: false,
},
// {
// title: "视频静音",
Expand Down
4 changes: 2 additions & 2 deletions src/internal/app/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class ToolsQuestionBank implements QuestionBank {
let val = topic[t];
body += "topic[" + (t - index) + "]=" + encodeURIComponent((val.topic)) + "&type[" + (t - index) + "]=" + val.type + "&";
}
Application.App.log.Debug("请求题库", {body});
Application.App.log.Debug("请求题库", {body}, JSON.stringify(topic));
HttpUtils.HttpPost(SystemConfig.url + "v2/answer?platform=" + this.platform, body, {
headers: {
"Authorization": Application.App.config.vtoken,
Expand Down Expand Up @@ -327,7 +327,7 @@ export class ToolsQuestionBankFacade implements QuestionBankFacade {
this.bank.Answer(topic, (ret: { status: QuestionStatus, answer: Answer[] }): Promise<void> => {
return new Promise(async (resolve) => {
if (ret.status != "processing") {
Application.App.log.Debug("题库返回", ret);
Application.App.log.Debug("题库返回", ret, JSON.stringify(ret));
if (ret.status != "success" || status == "success") {
callback(ret.status);
return resolve();
Expand Down
12 changes: 11 additions & 1 deletion src/internal/utils/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export class PageLog implements Logger {
protected toStr(...args: any): string {
let text = "";
for (let i = 0; i < args.length; i++) {
if (typeof args[i] == "object") {
if (typeof args[i] == "object" && args[i] !== null) {
text += args[i].toString() + "\n";
} else {
text += args[i] + "\n";
Expand All @@ -218,6 +218,16 @@ export class PageLog implements Logger {
}

public Debug(...args: any): Logger {
if (Application.App.debug) {
let text = this.toStr(...args);
let display = () =>
this.first(text, "#66CCFF", "rgba(121, 187, 255, 0.2)");
if (this.el) {
display();
} else {
this.queue.push(display);
}
}
console.info("[debug", this.getNowTime(), "]", ...args);
return this;
}
Expand Down
2 changes: 2 additions & 0 deletions src/mooc/chaoxing/course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class CxCourse extends EventListener<MoocEvent> implements MoocTaskSet {
public Init(): Promise<any> {
return new Promise(resolve => {
let first = true;
Application.App.log.Debug("CxCourse Init");
document.addEventListener("load", ev => {
let el = <HTMLIFrameElement>(ev.srcElement || ev.target);
if (el.id == "iframe") {
Expand Down Expand Up @@ -73,6 +74,7 @@ export class CxCourse extends EventListener<MoocEvent> implements MoocTaskSet {
// 任务工厂去创建对应的任务对象
task = TaskFactory.CreateCourseTask(iframeWindow, value);
if (!task) {
Application.App.log.Debug("!task: " + JSON.stringify(value));
continue;
}
task.jobIndex = index;
Expand Down
3 changes: 3 additions & 0 deletions src/mooc/chaoxing/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export class CxPlatform implements MoocFactory {
public CreateMooc(): Mooc {
let url = document.URL;
let mooc: Mooc = null;
Application.App.log.Debug("Checking cx mooc: " + url);
if (url.indexOf("mycourse/studentstudy?") > 0) {
Application.App.log.Debug("cx crouse");
new VCode(new CxCourseVCode());//添加打码组件
mooc = new CxCourse();
} else if (url.indexOf("ananas/modules/video/index.html") > 0) {
Expand All @@ -30,6 +32,7 @@ export class CxPlatform implements MoocFactory {
mooc = new Exam();
}
if (mooc) {
Application.App.log.Debug("CreateMooc=cx");
Application.App.config.SetNamespace("cx");
}
return mooc;
Expand Down
32 changes: 27 additions & 5 deletions src/mooc/chaoxing/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
PushAnswer
} from "@App/internal/app/question";
import { CreateNoteLine } from "./utils";
import { Application } from "@App/internal/application";

//TODO: 优化
export class CxQuestionFactory {
Expand Down Expand Up @@ -196,6 +197,7 @@ abstract class cxQuestion implements Question {
}

public AddNotice(str: string) {
Application.App.log.Debug("AddNotice=" + str);
CxQuestionFactory.AddNotice(this.el, str);
}

Expand Down Expand Up @@ -254,13 +256,27 @@ class cxSelectQuestion extends cxQuestion implements Question {
}

protected getOption(el: HTMLElement): string {
return el.querySelector("input").value;
console.log(el);
if (el.querySelector("input")) {
return el.querySelector("input").value;
} else if (el.querySelector(".num_option")) {
return el.querySelector(".num_option").getAttribute("data");
} else {
Application.App.log.Fatal("getOption failed!")
throw new Error();
}
}

protected click(el: HTMLElement, content: string) {
let ipt = (<HTMLInputElement>el.querySelector("label > input"));
if (!ipt.checked) {
ipt.click();
if (ipt) {
if (!ipt.checked) {
ipt.click();
}
} else if (el.role === "checkbox") {
if (!el.ariaChecked) {
el.click();
}
}
this.AddNotice(this.getOption(el) + ":" + content);
}
Expand Down Expand Up @@ -332,8 +348,14 @@ class cxJudgeQuestion extends cxSelectQuestion implements Question {

protected click(el: HTMLElement) {
let tmpel = (<HTMLInputElement>el.querySelector("label > input,input"));
if (!tmpel.checked) {
tmpel.click();
if (tmpel) {
if (!tmpel.checked) {
tmpel.click();
}
} else if (el.role === "checkbox") {
if (!el.ariaChecked) {
el.click();
}
}
this.AddNotice(this.getContent(el));
}
Expand Down
16 changes: 13 additions & 3 deletions src/mooc/chaoxing/special.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,26 @@ import { TaskType } from "@App/internal/app/task";

export class CxDocumentTask extends CxTask {
protected time: NodeJS.Timer;
protected prevTop: Number;

public Start(): Promise<void> {
return new Promise(resolve => {
let conWin = this.context.document.getElementById("panView").contentWindow;
this.prevTop = conWin.document.documentElement.scrollTop;
let next = () => {
let el = this.context.document.querySelector(".imglook > .mkeRbtn");
if (el.style.visibility == "hidden") {
conWin.scrollTo({
top: conWin.document.documentElement.scrollHeight - conWin.innerHeight,
left: 0,
behavior: "smooth"
});
if (conWin.document.documentElement.scrollTop + conWin.innerHeight + 1 > conWin.document.documentElement.scrollHeight) {
conWin.document.documentElement.scrollTo({
top: this.prevTop,
behavior: "smooth"
});
this.callEvent("complete");
return;
}
el.click();
this.time = this.context.setTimeout(next, randNumber(1, 5) * 1000);
resolve();
};
Expand Down
8 changes: 6 additions & 2 deletions src/mooc/chaoxing/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export class CxVideoOptimization implements Mooc {
return;
}
Application.App.log.Debug("hook cx video");
// Application.App.log.Info("视频工具已失效");
return;

let dataHook = new Hook("decode", (<any>Application.GlobalContext).Ext);
let self = this;
dataHook.Middleware(function (next: Context, ...args: any) {
Expand Down Expand Up @@ -211,8 +214,9 @@ export class Video extends CxTask {
}

protected initPlayer() {
this.playbackRate = this._playbackRate;
this.muted = this._muted;
// TODO
// this.playbackRate = this._playbackRate;
// this.muted = this._muted;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/mooc/mooc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export class mooc implements Launcher {
if ((<MoocTaskSet>mooc).Next != undefined) {
this.runMoocTask(<MoocTaskSet>mooc);
}
} else {
Application.App.log.Debug("CreateMooc is null");
}
} catch (e) {
Application.App.log.Fatal("扩展发生了一个致命错误:", e);
Expand Down
2 changes: 1 addition & 1 deletion src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ async function init() {
application.run();
}

console.log("start.js called --- init...")
console.log(`start.js called on ${document.URL} --- init...`)
init();

0 comments on commit 5b0409b

Please sign in to comment.