mirror of
https://github.com/JoeanAmier/XHS-Downloader.git
synced 2025-12-25 20:36:47 +08:00
feat(script): 脚本设置新增 菜单始终显示 配置项
This commit is contained in:
parent
7102565c64
commit
b3f0c7afb6
@ -566,7 +566,7 @@ class XHS:
|
||||
):
|
||||
@server.get(
|
||||
"/",
|
||||
summary=_("访问项目 GitHub 仓库"),
|
||||
summary=_("跳转至项目 GitHub 仓库"),
|
||||
description=_("重定向至项目 GitHub 仓库主页"),
|
||||
tags=["API"],
|
||||
)
|
||||
|
||||
@ -18,7 +18,8 @@
|
||||
|
||||
**用户脚本更新内容:**
|
||||
|
||||
**版本号:2.0.4**
|
||||
**版本号:2.1.0**
|
||||
|
||||
1. 修复单张图片的作品下载后文件损坏问题
|
||||
2. 修复用户脚本 CSS 样式冲突问题
|
||||
2. 脚本设置新增 `菜单始终显示` 配置项
|
||||
3. 修复用户脚本 CSS 样式冲突问题
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name XHS-Downloader
|
||||
// @namespace https://github.com/JoeanAmier/XHS-Downloader
|
||||
// @version 2.0.4
|
||||
// @version 2.1.0
|
||||
// @description 提取小红书作品/用户链接,下载小红书无水印图文/视频作品文件
|
||||
// @author JoeanAmier
|
||||
// @match http*://xhslink.com/*
|
||||
@ -33,6 +33,7 @@
|
||||
packageDownloadFiles: GM_getValue("packageDownloadFiles", true),
|
||||
autoScrollSwitch: GM_getValue("autoScrollSwitch", false),
|
||||
maxScrollCount: GM_getValue("maxScrollCount", 50),
|
||||
keepMenuVisible: GM_getValue("keepMenuVisible", false),
|
||||
fileNameFormat: undefined,
|
||||
imageFileFormat: undefined,
|
||||
icon: {
|
||||
@ -128,6 +129,16 @@ XHS-Downloader 用户脚本 详细说明:
|
||||
GM_setValue("maxScrollCount", config.maxScrollCount);
|
||||
};
|
||||
|
||||
const updateKeepMenuVisible = (value) => {
|
||||
config.keepMenuVisible = value;
|
||||
GM_setValue("keepMenuVisible", config.keepMenuVisible);
|
||||
if (config.keepMenuVisible) {
|
||||
showMenu();
|
||||
} else {
|
||||
hideMenu();
|
||||
}
|
||||
};
|
||||
|
||||
const updateFileNameFormat = (value) => {
|
||||
config.fileNameFormat = value;
|
||||
GM_setValue("fileNameFormat", config.fileNameFormat);
|
||||
@ -280,8 +291,7 @@ XHS-Downloader 用户脚本 详细说明:
|
||||
"headers": {
|
||||
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
||||
"accept-language": "zh-SG,zh;q=0.9",
|
||||
},
|
||||
"method": "GET",
|
||||
}, "method": "GET",
|
||||
});
|
||||
|
||||
// 检查响应状态码
|
||||
@ -869,7 +879,7 @@ XHS-Downloader 用户脚本 详细说明:
|
||||
const filePack = createSettingItem({
|
||||
label: '文件打包下载',
|
||||
description: '启用后,多个文件的作品将会以压缩包格式下载',
|
||||
checked: GM_getValue("packageDownloadFiles", true)
|
||||
checked: GM_getValue("packageDownloadFiles", true),
|
||||
});
|
||||
|
||||
// 滚动次数设置
|
||||
@ -882,6 +892,12 @@ XHS-Downloader 用户脚本 详细说明:
|
||||
disabled: !GM_getValue("autoScrollSwitch", false),
|
||||
});
|
||||
|
||||
const keepMenuVisible = createSettingItem({
|
||||
label: '菜单保持显示',
|
||||
description: '启用后,功能菜单无需鼠标悬停始终保持显示',
|
||||
checked: GM_getValue("keepMenuVisible", false),
|
||||
});
|
||||
|
||||
// 名称格式设置
|
||||
// const nameFormat = createTextInput({
|
||||
// label: '文件名称格式',
|
||||
@ -900,6 +916,7 @@ XHS-Downloader 用户脚本 详细说明:
|
||||
body.appendChild(filePack);
|
||||
body.appendChild(autoScroll);
|
||||
body.appendChild(scrollCount);
|
||||
body.appendChild(keepMenuVisible);
|
||||
// body.appendChild(nameFormat);
|
||||
|
||||
// 创建底部按钮
|
||||
@ -925,6 +942,7 @@ XHS-Downloader 用户脚本 详细说明:
|
||||
saveBtn.addEventListener('click', () => {
|
||||
updateAutoScrollSwitch(autoScroll.querySelector('input').checked);
|
||||
updatePackageDownloadFiles(filePack.querySelector('input').checked);
|
||||
updateKeepMenuVisible(keepMenuVisible.querySelector('input').checked);
|
||||
updateMaxScrollCount(parseInt(scrollCount.querySelector('input').value) || 50)
|
||||
// updateFileNameFormat(nameFormat.querySelector('.text-input').value.trim() || null);
|
||||
closeSettingsModal();
|
||||
@ -1406,6 +1424,9 @@ XHS-Downloader 用户脚本 详细说明:
|
||||
let hideTimeout;
|
||||
|
||||
const hideMenu = () => {
|
||||
if (config.keepMenuVisible) {
|
||||
return;
|
||||
}
|
||||
hideTimeout = setTimeout(() => {
|
||||
menu.classList.remove('menu-enter');
|
||||
menu.classList.add('menu-exit');
|
||||
@ -1564,4 +1585,8 @@ XHS-Downloader 用户脚本 详细说明:
|
||||
document.body.appendChild(menu);
|
||||
document.head.appendChild(style);
|
||||
setupUrlListener();
|
||||
|
||||
if (config.keepMenuVisible) {
|
||||
showMenu();
|
||||
}
|
||||
})();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user