更新脚本版本号至2026-06-10.1,优化配置菜单的显示逻辑,简化代码结构
This commit is contained in:
parent
26d41ae4d8
commit
8c48de9be0
|
|
@ -1,7 +1,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name 平顶山学院(青书学堂)自动学习脚本
|
// @name 平顶山学院(青书学堂)自动学习脚本
|
||||||
// @namespace http://tampermonkey.net/
|
// @namespace http://tampermonkey.net/
|
||||||
// @version 2026-06-05.8
|
// @version 2026-06-10.1
|
||||||
// @description 自动进入青书学堂未完成课件,支持视频播放、文本课件停留和运行状态提示
|
// @description 自动进入青书学堂未完成课件,支持视频播放、文本课件停留和运行状态提示
|
||||||
// @author JK
|
// @author JK
|
||||||
// @license MIT
|
// @license MIT
|
||||||
|
|
@ -179,7 +179,10 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const promptNumberConfig = (label, key, unit, currentValue, toStoredValue) => {
|
const promptNumberConfig = (label, key, unit, currentValue, toStoredValue) => {
|
||||||
const input = prompt(label + "(当前:" + currentValue + unit + ")", currentValue);
|
const input = prompt(
|
||||||
|
label + "(当前:" + currentValue + unit + ")",
|
||||||
|
currentValue
|
||||||
|
);
|
||||||
|
|
||||||
if (input === null) {
|
if (input === null) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -200,62 +203,87 @@
|
||||||
// 在 Tampermonkey 菜单里提供配置入口。
|
// 在 Tampermonkey 菜单里提供配置入口。
|
||||||
// 这些值保存在脚本存储区,脚本更新不会覆盖它们。
|
// 这些值保存在脚本存储区,脚本更新不会覆盖它们。
|
||||||
const registerConfigMenus = () => {
|
const registerConfigMenus = () => {
|
||||||
GM_registerMenuCommand("设置视频倍速", () => {
|
const menuTitle = (label, value, unit) =>
|
||||||
promptNumberConfig(
|
label + "(当前:" + value + unit + ")";
|
||||||
"设置视频倍速",
|
|
||||||
"videoPlaybackRate",
|
|
||||||
"倍",
|
|
||||||
CONFIG.videoPlaybackRate
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
GM_registerMenuCommand("设置课件最小学习时间", () => {
|
GM_registerMenuCommand(
|
||||||
promptNumberConfig(
|
menuTitle("设置视频倍速", CONFIG.videoPlaybackRate, "倍"),
|
||||||
"设置课件最小学习时间",
|
() => {
|
||||||
"minStudySeconds",
|
promptNumberConfig(
|
||||||
"分钟",
|
"设置视频倍速",
|
||||||
CONFIG.minStudySeconds / 60,
|
"videoPlaybackRate",
|
||||||
(value) => value * 60
|
"倍",
|
||||||
);
|
CONFIG.videoPlaybackRate
|
||||||
});
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
GM_registerMenuCommand("设置运行提醒间隔", () => {
|
GM_registerMenuCommand(
|
||||||
promptNumberConfig(
|
menuTitle("设置课件最小学习时间", CONFIG.minStudySeconds / 60, "分钟"),
|
||||||
"设置运行提醒间隔",
|
() => {
|
||||||
"heartbeatSeconds",
|
promptNumberConfig(
|
||||||
"秒",
|
"设置课件最小学习时间",
|
||||||
CONFIG.heartbeatSeconds
|
"minStudySeconds",
|
||||||
);
|
"分钟",
|
||||||
});
|
CONFIG.minStudySeconds / 60,
|
||||||
|
(value) => value * 60
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
GM_registerMenuCommand("设置课程列表等待时间", () => {
|
GM_registerMenuCommand(
|
||||||
promptNumberConfig(
|
menuTitle("设置运行提醒间隔", CONFIG.heartbeatSeconds, "秒"),
|
||||||
"设置课程列表等待时间",
|
() => {
|
||||||
"courseListWaitSeconds",
|
promptNumberConfig(
|
||||||
"秒",
|
"设置运行提醒间隔",
|
||||||
CONFIG.courseListWaitSeconds
|
"heartbeatSeconds",
|
||||||
);
|
"秒",
|
||||||
});
|
CONFIG.heartbeatSeconds
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
GM_registerMenuCommand("设置课程列表自动刷新次数", () => {
|
GM_registerMenuCommand(
|
||||||
promptNumberConfig(
|
menuTitle("设置课程列表等待时间", CONFIG.courseListWaitSeconds, "秒"),
|
||||||
|
() => {
|
||||||
|
promptNumberConfig(
|
||||||
|
"设置课程列表等待时间",
|
||||||
|
"courseListWaitSeconds",
|
||||||
|
"秒",
|
||||||
|
CONFIG.courseListWaitSeconds
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
GM_registerMenuCommand(
|
||||||
|
menuTitle(
|
||||||
"设置课程列表自动刷新次数",
|
"设置课程列表自动刷新次数",
|
||||||
"maxCourseListRefreshCount",
|
|
||||||
"次",
|
|
||||||
CONFIG.maxCourseListRefreshCount,
|
CONFIG.maxCourseListRefreshCount,
|
||||||
Math.floor
|
"次"
|
||||||
);
|
),
|
||||||
});
|
() => {
|
||||||
|
promptNumberConfig(
|
||||||
|
"设置课程列表自动刷新次数",
|
||||||
|
"maxCourseListRefreshCount",
|
||||||
|
"次",
|
||||||
|
CONFIG.maxCourseListRefreshCount,
|
||||||
|
Math.floor
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
GM_registerMenuCommand("设置提示消息显示时间", () => {
|
GM_registerMenuCommand(
|
||||||
promptNumberConfig(
|
menuTitle("设置提示消息显示时间", CONFIG.toastDefaultDuration / 1000, "秒"),
|
||||||
"设置提示消息显示时间",
|
() => {
|
||||||
"toastDefaultDuration",
|
promptNumberConfig(
|
||||||
"秒",
|
"设置提示消息显示时间",
|
||||||
CONFIG.toastDefaultDuration / 1000,
|
"toastDefaultDuration",
|
||||||
(value) => value * 1000
|
"秒",
|
||||||
);
|
CONFIG.toastDefaultDuration / 1000,
|
||||||
});
|
(value) => value * 1000
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
GM_registerMenuCommand("恢复默认设置", () => {
|
GM_registerMenuCommand("恢复默认设置", () => {
|
||||||
GM_deleteValue(CONFIG_STORAGE_KEY);
|
GM_deleteValue(CONFIG_STORAGE_KEY);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue