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