您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
获取淘宝直播弹幕信息并发送详情
当前为
// ==UserScript== // @name 淘宝弹幕助手v1 // @namespace http://tampermonkey.net/ // @version 4.0 // @description 获取淘宝直播弹幕信息并发送详情 // @match https://liveplatform.taobao.com // @match https://liveplatform.taobao.com/restful/index/live/control/* // @icon https://cdn.52ym.vip/temp/a0whr-l6z8y-001.ico // @grant none // @license MIT // ==/UserScript== console.log("开启直播了..................") const TIME = 3000; const liveDetailUrl = "" const platformMap = new Map([ ['liveplatform.taobao.com', handleTaoBaoBarrage] ]); let barrageIds = []; // 存储已处理的弹幕ID // const WS = new WebSocket(HOST); // 创建WebSocket对象 // WS.onopen = function () { // console.log('连接成功'); // }; // WS.onclose = function () { // console.log('断开连接'); // }; function handleRequest(username, content, id) { // 构造弹幕数据对象 let data = { nickname: username, content: content }; console.log(data); // 发送弹幕数据到WebSocket服务器 // WS.send(JSON.stringify(data)); // 将已处理的弹幕ID添加到列表中 barrageIds.push(id); if (barrageIds.length > 300) { barrageIds.splice(0, 100); } } function handleTaoBaoBarrage() { let barrageContainer = document.querySelector('.alpw-container > div.alpw-comment-item:last-child'); console.log("current barrageContainer:",barrageContainer) if (!barrageContainer) { return; // Exit if the barrage container element is not found } let barrageElements = barrageContainer.querySelectorAll('div.alpw-comment-item'); for (let i = 0; i < barrageElements.length; i++) { let barrageElement = barrageElements[i]; let usernameElement = barrageElement.querySelector('div.alpw-userinfo > div.alpw-left > div.alpw-username > div.alpw-username-text'); let contentElement = barrageElement.querySelector('div.alpw-comment-content'); // 检查弹幕元素是否存在 if (!usernameElement || !contentElement) { continue; // Skip if either username or content element is not found } let username = usernameElement.textContent.trim(); let content = contentElement.textContent.trim(); let id = username + content; // 检查是否已处理过该弹幕 if (barrageIds.includes(id)) { continue; } handleRequest(username, content, id); } } (function () { const currUrl = window.location.href platformMap.forEach((value, key) => { if (currUrl.indexOf(key) !== -1) { setInterval(value, TIME); } }) })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址