feat: 添加自定义排除UID列表功能,增强数据筛选能力
在产品历史KOC助手中新增自定义排除UID列表功能,用户可以通过配置需要排除的达人UID,提升数据筛选的灵活性和准确性。同时,增加了相关的日志记录,便于用户了解排除列表的状态。这一改进优化了数据采集过程,确保用户能够更有效地管理和分析数据。
This commit is contained in:
parent
ce078e9da6
commit
3dc1b5f09d
@ -1,6 +1,6 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name 蝉妈妈产品历史KOC助手
|
// @name 蝉妈妈产品历史KOC助手
|
||||||
// @namespace https://github.com/scriptCat/
|
// @namespace https://bbs.tampermonkey.net.cn/
|
||||||
// @version 1.0.0
|
// @version 1.0.0
|
||||||
// @description 蝉妈妈平台产品历史KOC数据分析和导出助手
|
// @description 蝉妈妈平台产品历史KOC数据分析和导出助手
|
||||||
// @author wangxi
|
// @author wangxi
|
||||||
@ -83,6 +83,11 @@ filters:
|
|||||||
description: 达人粉丝数上限,只采集粉丝数少于此数值的达人
|
description: 达人粉丝数上限,只采集粉丝数少于此数值的达人
|
||||||
type: number
|
type: number
|
||||||
default: 500000
|
default: 500000
|
||||||
|
excludeUIDs:
|
||||||
|
title: 自定义排除列表
|
||||||
|
description: 需要排除的达人UID列表,每行一个UID(如:redian0805)
|
||||||
|
type: textarea
|
||||||
|
default: ""
|
||||||
==/UserConfig== */
|
==/UserConfig== */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
@ -112,7 +117,8 @@ filters:
|
|||||||
},
|
},
|
||||||
filters: {
|
filters: {
|
||||||
videoRatioThreshold: GM_getValue('filters.videoRatioThreshold', 0.5),
|
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: {
|
feishu: {
|
||||||
enabled: GM_getValue('feishu.enableSync', false),
|
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') {
|
function log(message, level = 'info') {
|
||||||
const logMessage = `[${GM_info.script.name}] ${message}`;
|
const logMessage = `[${GM_info.script.name}] ${message}`;
|
||||||
// 强制输出所有日志到GM日志和控制台,便于调试
|
// 强制输出所有日志到GM日志和控制台,便于调试
|
||||||
@ -969,6 +994,15 @@ filters:
|
|||||||
let currentPage = 1;
|
let currentPage = 1;
|
||||||
let shouldContinue = true;
|
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) {
|
while (shouldContinue) {
|
||||||
log(`请求第 ${currentPage} 页数据`, 'info');
|
log(`请求第 ${currentPage} 页数据`, 'info');
|
||||||
|
|
||||||
@ -1011,6 +1045,12 @@ filters:
|
|||||||
|
|
||||||
// 应用筛选条件
|
// 应用筛选条件
|
||||||
const filteredData = parsedData.filter(author => {
|
const filteredData = parsedData.filter(author => {
|
||||||
|
// 检查自定义排除列表
|
||||||
|
if (excludeUIDs.has(author.达人UID)) {
|
||||||
|
log(`筛选掉达人 ${author.昵称} (${author.达人UID}): 在自定义排除列表中`, 'debug');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// 检查金额门槛
|
// 检查金额门槛
|
||||||
if (author.预估关联商品视频销售金额 < CONFIG.pagination.amountThreshold) {
|
if (author.预估关联商品视频销售金额 < CONFIG.pagination.amountThreshold) {
|
||||||
log(`筛选掉达人 ${author.昵称}: 视频销售金额 ${author.预估关联商品视频销售金额} < ${CONFIG.pagination.amountThreshold}`, 'debug');
|
log(`筛选掉达人 ${author.昵称}: 视频销售金额 ${author.预估关联商品视频销售金额} < ${CONFIG.pagination.amountThreshold}`, 'debug');
|
||||||
@ -1212,6 +1252,14 @@ filters:
|
|||||||
log(` - 粉丝数上限: <${CONFIG.filters.maxFollowers.toLocaleString()}`, 'info');
|
log(` - 粉丝数上限: <${CONFIG.filters.maxFollowers.toLocaleString()}`, 'info');
|
||||||
log(` - 视频带货占比: ≥${(CONFIG.filters.videoRatioThreshold * 100).toFixed(1)}%`, '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();
|
await waitForPageLoad();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user