From 3dc1b5f09dfaaa22b3f68f10d814d867278777d8 Mon Sep 17 00:00:00 2001 From: intelligrow <15511098+intelligrow@user.noreply.gitee.com> Date: Tue, 24 Jun 2025 17:34:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=8E=92=E9=99=A4UID=E5=88=97=E8=A1=A8=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E5=A2=9E=E5=BC=BA=E6=95=B0=E6=8D=AE=E7=AD=9B?= =?UTF-8?q?=E9=80=89=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在产品历史KOC助手中新增自定义排除UID列表功能,用户可以通过配置需要排除的达人UID,提升数据筛选的灵活性和准确性。同时,增加了相关的日志记录,便于用户了解排除列表的状态。这一改进优化了数据采集过程,确保用户能够更有效地管理和分析数据。 --- chanmama/productHistoryKOCHelper.user.js | 52 +++++++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/chanmama/productHistoryKOCHelper.user.js b/chanmama/productHistoryKOCHelper.user.js index a146d02..690661e 100644 --- a/chanmama/productHistoryKOCHelper.user.js +++ b/chanmama/productHistoryKOCHelper.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 蝉妈妈产品历史KOC助手 -// @namespace https://github.com/scriptCat/ +// @namespace https://bbs.tampermonkey.net.cn/ // @version 1.0.0 // @description 蝉妈妈平台产品历史KOC数据分析和导出助手 // @author wangxi @@ -83,6 +83,11 @@ filters: description: 达人粉丝数上限,只采集粉丝数少于此数值的达人 type: number default: 500000 + excludeUIDs: + title: 自定义排除列表 + description: 需要排除的达人UID列表,每行一个UID(如:redian0805) + type: textarea + default: "" ==/UserConfig== */ (function() { @@ -112,7 +117,8 @@ filters: }, filters: { videoRatioThreshold: GM_getValue('filters.videoRatioThreshold', 0.5), - maxFollowers: GM_getValue('filters.maxFollowers', 500000) + maxFollowers: GM_getValue('filters.maxFollowers', 500000), + excludeUIDs: GM_getValue('filters.excludeUIDs', '') }, feishu: { enabled: GM_getValue('feishu.enableSync', false), @@ -131,6 +137,25 @@ filters: }; // 工具函数 + /** + * 解析自定义排除UID列表 + * @param {string} excludeText - 多行文本,每行一个UID + * @returns {Set} 包含所有需要排除的UID的Set + */ + function parseExcludeUIDs(excludeText) { + if (!excludeText || typeof excludeText !== 'string') { + return new Set(); + } + + // 按行分割,去除空行和空白字符 + const uids = excludeText + .split('\n') + .map(line => line.trim()) + .filter(line => line.length > 0); + + return new Set(uids); + } + function log(message, level = 'info') { const logMessage = `[${GM_info.script.name}] ${message}`; // 强制输出所有日志到GM日志和控制台,便于调试 @@ -969,6 +994,15 @@ filters: let currentPage = 1; let shouldContinue = true; + // 解析自定义排除UID列表 + const excludeUIDs = parseExcludeUIDs(CONFIG.filters.excludeUIDs); + if (excludeUIDs.size > 0) { + log(`自定义排除列表包含 ${excludeUIDs.size} 个达人UID`, 'info'); + log(`排除列表: ${Array.from(excludeUIDs).join(', ')}`, 'debug'); + } else { + log('未配置自定义排除列表', 'debug'); + } + while (shouldContinue) { log(`请求第 ${currentPage} 页数据`, 'info'); @@ -1011,6 +1045,12 @@ filters: // 应用筛选条件 const filteredData = parsedData.filter(author => { + // 检查自定义排除列表 + if (excludeUIDs.has(author.达人UID)) { + log(`筛选掉达人 ${author.昵称} (${author.达人UID}): 在自定义排除列表中`, 'debug'); + return false; + } + // 检查金额门槛 if (author.预估关联商品视频销售金额 < CONFIG.pagination.amountThreshold) { log(`筛选掉达人 ${author.昵称}: 视频销售金额 ${author.预估关联商品视频销售金额} < ${CONFIG.pagination.amountThreshold}`, 'debug'); @@ -1212,6 +1252,14 @@ filters: log(` - 粉丝数上限: <${CONFIG.filters.maxFollowers.toLocaleString()}`, 'info'); log(` - 视频带货占比: ≥${(CONFIG.filters.videoRatioThreshold * 100).toFixed(1)}%`, 'info'); + // 显示自定义排除列表信息 + const excludeUIDs = parseExcludeUIDs(CONFIG.filters.excludeUIDs); + if (excludeUIDs.size > 0) { + log(` - 自定义排除: ${excludeUIDs.size} 个达人UID`, 'info'); + } else { + log(` - 自定义排除: 未配置`, 'info'); + } + // 等待页面加载完成 await waitForPageLoad();