intelligrow 3c3ecf8947 feat: 新增多个脚本用于监控抖音直播、店铺评价、售后及体验分数据
新增了多个脚本文件,用于监控抖音直播间的弹幕、店铺评价、售后数据及商家体验分。这些脚本通过飞书多维表格进行数据存储,并支持定时任务自动更新数据。具体包括:
1. 直播间弹幕监控脚本
2. 店铺评价监控脚本
3. 售后数据监控脚本
4. 商家体验分监控脚本
5. 竞品、行业及跨行业热门千川素材获取脚本

这些脚本通过飞书API进行数据写入,并支持去重和定时任务调度。
2025-04-25 15:15:29 +08:00

150 lines
5.9 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ==UserScript==
// @name 罗盘直播大屏弹幕监听
// @namespace https://bbs.tampermonkey.net.cn/
// @version 0.3.0
// @description 监听直播间弹幕
// @author 汪喜
// @match https://compass.jinritemai.com/screen/live*
// @grant GM_xmlhttpRequest
// @require https://scriptcat.org/lib/637/1.4.3/ajaxHooker.js#sha256=y1sWy1M/U5JP1tlAY5e80monDp27fF+GMRLsOiIrSUY=
// ==/UserScript==
(function () {
'use strict';
//一些更改
// 添加一个按钮来控制监听状态
function addToggleButton() {
// 使用setTimeout来延迟按钮的添加
setTimeout(() => {
const targetContainerSelector = '.header--XNxuk';
const targetContainer = document.querySelector(targetContainerSelector);
if (!targetContainer) {
console.error('The target container for the toggle button was not found.');
return;
}
const button = document.createElement('button');
button.textContent = '开始监听';
button.style.marginLeft = '10px';
let isListening = false;
button.addEventListener('click', () => {
if (isListening) {
ah.unProxy();
button.textContent = '开始监听';
isListening = false;
alert('监听结束');
} else {
startListening();
button.textContent = '监听中 点击停止';
isListening = true;
alert('监听开始');
}
});
targetContainer.appendChild(button);
}, 3000); // 延迟3000毫秒3秒后执行
}
window.addEventListener('load', addToggleButton);
const appId = "cli_a6f25876ea28100d";
const appSecret = "raLC56ZLIara07nKigpysfoDxHTAeyJf";
const appToken = 'HyV1bstZra3P1xstDiecfCSjnLe'; //多维表格appToken
const tableId = 'tblEqZ2x8eujgl0c'; //多维表格tableId
class FeishuAPI {
constructor() {
this.tenantAccessToken = null;
}
async getTenantAccessToken() {
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: "POST",
url: "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal/",
headers: {
"Content-Type": "application/json",
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
"app_id": appId,
"app_secret": appSecret
}),
onload: (response) => {
if (response.status === 200 && response.responseText) {
let responseData = JSON.parse(response.responseText);
this.tenantAccessToken = responseData.tenant_access_token;
console.log('Tenant Access Token:', this.tenantAccessToken);
resolve(this.tenantAccessToken);
} else {
console.error('Failed to get tenant access token:', response.statusText);
reject(new Error('Failed to get tenant access token'));
}
}
});
});
}
async writeIntoBase(dataItem) {
if (!this.tenantAccessToken) {
await this.getTenantAccessToken();
}
return new Promise((resolve, reject) => {
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${this.tenantAccessToken}`,
};
const requestBody = {
fields: dataItem
};
GM_xmlhttpRequest({
method: 'POST',
url: `https://open.feishu.cn/open-apis/bitable/v1/apps/${appToken}/tables/${tableId}/records`,
headers: headers,
data: JSON.stringify(requestBody),
onload: function (response) {
if (response.status === 200) {
console.log('Data written to Feishu successfully:', response.responseText);
resolve(response.responseText);
} else {
console.error('Failed to write data:', response.statusText);
reject(new Error(`HTTP error! Status: ${response.status}`));
}
},
onerror: function (error) {
console.error('Request failed:', error);
reject(new Error('Request failed'));
}
});
});
}
}
function startListening() {
ajaxHooker.hook(request => {
if (request.url.includes('https://compass.jinritemai.com/business_api/shop/live_bigscreen/comment')) {
request.response = async res => {
const jsonResponse = await res.json();
const comments = jsonResponse.data.comments;
comments.forEach(async (comment) => {
const dataItem = {
nickname: comment.nick_name,
content: comment.content,
createtime: Math.round(new Date().getTime())
};
console.log(dataItem);
const feishuAPI = new FeishuAPI();
await feishuAPI.writeIntoBase(dataItem);
});
};
}
});
}
})();