diff --git a/static/Release_Notes.md b/static/Release_Notes.md index 513cef9..b73c79f 100644 --- a/static/Release_Notes.md +++ b/static/Release_Notes.md @@ -17,6 +17,8 @@ **用户脚本更新内容:** 1. 重构自动滚动页面功能 -2. 优化文件下载功能 +2. 新增文件名称长度限制 +3. 优化文件名称过滤规则 +4. 优化文件下载功能

注意:自动滚动页面功能默认关闭!启用该功能可能会被小红书检测为自动化操作,从而导致账号受到风控或封禁!该功能在使用过程中遇到任何问题请及时向开发者反馈!

diff --git a/static/XHS-Downloader.js b/static/XHS-Downloader.js index 7f83b18..1a8ff74 100644 --- a/static/XHS-Downloader.js +++ b/static/XHS-Downloader.js @@ -1,7 +1,7 @@ // ==UserScript== // @name XHS-Downloader // @namespace https://github.com/JoeanAmier/XHS-Downloader -// @version 1.8.1 +// @version 1.8.2 // @description 提取小红书作品/用户链接,下载小红书无水印图文/视频作品文件 // @author JoeanAmier // @match http*://xhslink.com/* @@ -290,8 +290,17 @@ XHS-Downloader 用户脚本 详细说明: return !hasError; // 如果没有错误返回 true,有错误则返回 false }; + const truncateString = (str, maxLength) => { + if (str.length > maxLength) { + const halfLength = Math.floor(maxLength / 2) - 1; // 减去 1 留出省略号的空间 + return str.slice(0, halfLength) + '...' + str.slice(-halfLength); + } + return str; + }; + const extractName = () => { - let name = document.title.replace(/[^\u4e00-\u9fa5a-zA-Z0-9]/g, ""); + let name = document.title.replace(/[^\u4e00-\u9fa5a-zA-Z0-9 ~!@#$%&()_\-+=\[\];"',.!()【】:“”《》?]/g, ""); + name = truncateString(name, 128,); let match = currentUrl.match(/\/([^\/]+)$/); let id = match ? match[1] : null; return name === "" ? id : name