// ==UserScript== // @name 抖音点赞/收藏/推荐(陈天翊测试版) // @namespace http://tampermonkey.net/ // @version 1.5 // @description 点赞、收藏、推荐 依据视频刷新量执行 // @author 陈天翊 // @match https://www.douyin.com/* // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @grant GM_addStyle // @grant unsafeWindow // @run-at document-idle // ==/UserScript== (function() { 'use strict'; // 配置 const CONFIG = { enabled: GM_getValue('enabled', true), // 点赞功能 autoLike: GM_getValue('autoLike', true), likeVideoMin: GM_getValue('likeVideoMin', 5), // 检测到3个新视频 likeVideoMax: GM_getValue('likeVideoMax', 12), // 检测到5个新视频 // 收藏功能 autoCollect: GM_getValue('autoCollect', true), collectVideoMin: GM_getValue('collectVideoMin', 20), // 检测到5个新视频 collectVideoMax: GM_getValue('collectVideoMax', 68), // 检测到8个新视频 // 推荐功能 autoShare: GM_getValue('autoShare', true), shareVideoMin: GM_getValue('shareVideoMin', 30), // 检测到2个新视频 shareVideoMax: GM_getValue('shareVideoMax', 100) // 检测到4个新视频 }; // 统计 const STATS = { likes: GM_getValue('likes', 0), collects: GM_getValue('collects', 0), shares: GM_getValue('shares', 0), successes: GM_getValue('successes', 0), failures: GM_getValue('failures', 0), videoCount: GM_getValue('videoCount', 0) // 累计新视频数量 }; // 当前状态 let currentState = { isProcessing: false, currentVideo: '', panelVisible: false, panel: null, panelMinimized: false, // 新增:面板是否最小化 likeCounter: 0, // 点赞计数器 collectCounter: 0, // 收藏计数器 shareCounter: 0 // 推荐计数器 }; class DouyinAutoHelper { constructor() { this.init(); } init() { console.log('👽 抖音点赞/收藏/推荐 v1.5 已加载(陈天翊测试版)'); this.setupMenuCommands(); this.addCSSStyles(); // 等待页面加载完成后初始化 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => this.delayedInit()); } else { this.delayedInit(); } } delayedInit() { setTimeout(() => { this.startVideoMonitoring(); if (CONFIG.enabled) { this.startAutoMode(); } // 默认显示控制面板 this.showControlPanel(); console.log('🚀 脚本初始化完成'); console.log('📊 当前执行规则:'); console.log('- 点赞:每' + CONFIG.likeVideoMin + '-' + CONFIG.likeVideoMax + '个新视频'); console.log('- 收藏:每' + CONFIG.collectVideoMin + '-' + CONFIG.collectVideoMax + '个新视频'); console.log('- 推荐:每' + CONFIG.shareVideoMin + '-' + CONFIG.shareVideoMax + '个新视频'); }, 3000); } setupMenuCommands() { if (typeof GM_registerMenuCommand === 'function') { GM_registerMenuCommand('🎮 显示控制面板', () => this.showControlPanel()); GM_registerMenuCommand('📊 查看统计', () => this.showStats()); GM_registerMenuCommand('▶️ 启动自动模式', () => this.startAutoMode()); GM_registerMenuCommand('⏸️ 停止自动模式', () => this.stopAutoMode()); GM_registerMenuCommand('🧹 重置统计', () => this.resetStats()); } } addCSSStyles() { const style = document.createElement('style'); style.textContent = ` .tianyi-panel { position: fixed; top: 20px; left: 20px; background: linear-gradient(135deg, #0f0c29, #302b63, #24243e); color: white; padding: 15px; border-radius: 10px; z-index: 10000; font-family: system-ui; font-size: 12px; min-width: 280px; box-shadow: 0 5px 20px rgba(0,0,0,0.3); border: 2px solid #4cc9f0; transition: all 0.3s ease; } .tianyi-panel-minimized { padding: 5px 15px; min-width: 120px; } .tianyi-panel-hidden { display: none; } .tianyi-panel-content { transition: all 0.3s ease; } .tianyi-panel-minimized .tianyi-panel-content { display: none; } .tianyi-notification { position: fixed; bottom: 20px; right: 20px; background: #0f0c29; color: white; padding: 10px 15px; border-radius: 5px; z-index: 10001; font-size: 14px; border-left: 4px solid #4cc9f0; animation: tianyiSlideIn 0.3s ease-out; } @keyframes tianyiSlideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } } .tianyi-btn { padding: 8px 12px; border: none; border-radius: 5px; color: white; cursor: pointer; margin: 2px; font-size: 11px; transition: all 0.3s; } .tianyi-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.3); } .tianyi-counter { font-size: 9px; opacity: 0.7; margin-top: 2px; } .tianyi-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; } .tianyi-minimize-btn { background: transparent; border: none; color: white; font-size: 16px; cursor: pointer; padding: 2px 8px; border-radius: 3px; transition: all 0.3s; } .tianyi-minimize-btn:hover { background: rgba(255,255,255,0.1); } .tianyi-minimized-content { display: flex; align-items: center; justify-content: space-between; width: 100%; } .tianyi-minimized-stats { display: flex; gap: 10px; } .tianyi-minimized-stat { font-size: 11px; text-align: center; } .tianyi-minimized-icon { font-size: 12px; margin-right: 2px; } .tianyi-minimized-count { font-weight: bold; font-size: 13px; } `; document.head.appendChild(style); } // ==================== 核心功能 ==================== getRandomCount(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } performLike() { console.log('执行点赞操作'); this.simulateKeyPress('z'); STATS.likes++; this.saveStats(); this.updatePanelStats(); // 重置计数器 currentState.likeCounter = 0; this.showNotification('❤️ 点赞成功'); STATS.successes++; this.saveStats(); } performCollect() { console.log('执行收藏操作'); this.simulateKeyPress('c'); STATS.collects++; this.saveStats(); this.updatePanelStats(); // 重置计数器 currentState.collectCounter = 0; this.showNotification('⭐ 收藏成功'); STATS.successes++; this.saveStats(); } performShare() { console.log('执行推荐操作'); this.simulateKeyPress('p'); STATS.shares++; this.saveStats(); this.updatePanelStats(); // 等待推荐面板打开后关闭 setTimeout(() => { this.simulateKeyPress('Escape'); }, 1000); // 重置计数器 currentState.shareCounter = 0; this.showNotification('📤 推荐成功'); STATS.successes++; this.saveStats(); } // ==================== 自动模式 ==================== startAutoMode() { CONFIG.enabled = true; GM_setValue('enabled', true); console.log('启动自动模式'); this.showNotification('👽 自动模式已启动'); this.updateControlPanel(); } stopAutoMode() { CONFIG.enabled = false; GM_setValue('enabled', false); console.log('停止自动模式'); this.showNotification('⏸️ 自动模式已停止'); this.updateControlPanel(); } toggleAutoMode() { if (CONFIG.enabled) { this.stopAutoMode(); } else { this.startAutoMode(); } } // 检测新视频 startVideoMonitoring() { let lastVideoSrc = ''; setInterval(() => { if (!CONFIG.enabled) return; const video = this.getVideoElement(); if (video && video.src && video.src !== lastVideoSrc) { console.log('🎬 检测到新视频'); lastVideoSrc = video.src; // 增加视频计数 STATS.videoCount++; this.saveStats(); // 增加各功能计数器 currentState.likeCounter++; currentState.collectCounter++; currentState.shareCounter++; // 更新面板显示 this.updatePanelStats(); // 检查是否满足执行条件 this.checkAndExecuteActions(); } }, 2000); } checkAndExecuteActions() { console.log('📊 计数器状态:'); console.log('- 点赞计数器:' + currentState.likeCounter + '/' + CONFIG.likeVideoMin + '-' + CONFIG.likeVideoMax); console.log('- 收藏计数器:' + currentState.collectCounter + '/' + CONFIG.collectVideoMin + '-' + CONFIG.collectVideoMax); console.log('- 推荐计数器:' + currentState.shareCounter + '/' + CONFIG.shareVideoMin + '-' + CONFIG.shareVideoMax); // 检查点赞条件 if (CONFIG.autoLike && currentState.likeCounter >= this.getRandomCount(CONFIG.likeVideoMin, CONFIG.likeVideoMax)) { console.log('✅ 满足点赞条件,执行点赞'); this.performLike(); } // 检查收藏条件 if (CONFIG.autoCollect && currentState.collectCounter >= this.getRandomCount(CONFIG.collectVideoMin, CONFIG.collectVideoMax)) { console.log('✅ 满足收藏条件,执行收藏'); this.performCollect(); } // 检查推荐条件 if (CONFIG.autoShare && currentState.shareCounter >= this.getRandomCount(CONFIG.shareVideoMin, CONFIG.shareVideoMax)) { console.log('✅ 满足推荐条件,执行推荐'); this.performShare(); } } // ==================== 控制面板 ==================== showControlPanel() { if (currentState.panel) { currentState.panel.classList.remove('tianyi-panel-hidden'); currentState.panelVisible = true; this.updateControlPanel(); return; } const panel = document.createElement('div'); panel.className = 'tianyi-panel'; panel.innerHTML = this.getPanelHTML(); document.body.appendChild(panel); this.setupPanelEvents(panel); this.makeDraggable(panel); currentState.panel = panel; currentState.panelVisible = true; } getPanelHTML() { if (currentState.panelMinimized) { return this.getMinimizedPanelHTML(); } return this.getFullPanelHTML(); } getFullPanelHTML() { return `
点赞/收藏/推荐(陈天翊测试版)
点赞
${STATS.likes}
${currentState.likeCounter}/${CONFIG.likeVideoMin}-${CONFIG.likeVideoMax}
收藏
${STATS.collects}
${currentState.collectCounter}/${CONFIG.collectVideoMin}-${CONFIG.collectVideoMax}
推荐
${STATS.shares}
${currentState.shareCounter}/${CONFIG.shareVideoMin}-${CONFIG.shareVideoMax}
累计视频: ${STATS.videoCount}
成功率: ${STATS.successes + STATS.failures > 0 ? Math.round((STATS.successes / (STATS.successes + STATS.failures)) * 100) : 0}%
执行规则
每N个新视频执行
❤️ 点赞 每 ${CONFIG.likeVideoMin}-${CONFIG.likeVideoMax} 个视频
⭐ 收藏 每 ${CONFIG.collectVideoMin}-${CONFIG.collectVideoMax} 个视频
📤 推荐 每 ${CONFIG.shareVideoMin}-${CONFIG.shareVideoMax} 个视频
手动操作
成功: ${STATS.successes} | 失败: ${STATS.failures}
点击➖可最小化面板 | 双击标题可切换自动模式
`; } getMinimizedPanelHTML() { return `
❤️
${STATS.likes}
${STATS.collects}
📤
${STATS.shares}
`; } setupPanelEvents(panel) { if (currentState.panelMinimized) { panel.querySelector('#tianyi-expand').addEventListener('click', () => this.toggleMinimize()); panel.querySelector('#tianyi-close').addEventListener('click', () => this.hideControlPanel()); } else { panel.querySelector('#tianyi-toggle').addEventListener('click', () => this.toggleAutoMode()); panel.querySelector('#tianyi-like').addEventListener('click', () => this.performLike()); panel.querySelector('#tianyi-collect').addEventListener('click', () => this.performCollect()); panel.querySelector('#tianyi-share').addEventListener('click', () => this.performShare()); panel.querySelector('#tianyi-minimize').addEventListener('click', () => this.toggleMinimize()); panel.querySelector('#tianyi-close').addEventListener('click', () => this.hideControlPanel()); // 双击标题切换自动模式 const title = panel.querySelector('.tianyi-panel-header strong'); title.addEventListener('dblclick', () => this.toggleAutoMode()); } } toggleMinimize() { currentState.panelMinimized = !currentState.panelMinimized; if (currentState.panel) { if (currentState.panelMinimized) { currentState.panel.classList.add('tianyi-panel-minimized'); } else { currentState.panel.classList.remove('tianyi-panel-minimized'); } // 重新渲染面板 currentState.panel.innerHTML = this.getPanelHTML(); this.setupPanelEvents(currentState.panel); this.updatePanelStats(); } this.showNotification(currentState.panelMinimized ? '📱 面板已最小化' : '📱 面板已展开'); } updateControlPanel() { if (!currentState.panel) return; if (!currentState.panelMinimized) { const toggleBtn = currentState.panel.querySelector('#tianyi-toggle'); if (toggleBtn) { toggleBtn.textContent = CONFIG.enabled ? '⏸️ 停止自动' : '▶️ 启动自动'; toggleBtn.style.background = CONFIG.enabled ? '#f72585' : '#4cc9f0'; } } } updatePanelStats() { if (!currentState.panel) return; if (currentState.panelMinimized) { const likesEl = currentState.panel.querySelector('#tianyi-stat-likes-mini'); const collectsEl = currentState.panel.querySelector('#tianyi-stat-collects-mini'); const sharesEl = currentState.panel.querySelector('#tianyi-stat-shares-mini'); if (likesEl) likesEl.textContent = STATS.likes; if (collectsEl) collectsEl.textContent = STATS.collects; if (sharesEl) sharesEl.textContent = STATS.shares; } else { const likesEl = currentState.panel.querySelector('#tianyi-stat-likes'); const collectsEl = currentState.panel.querySelector('#tianyi-stat-collects'); const sharesEl = currentState.panel.querySelector('#tianyi-stat-shares'); const videosEl = currentState.panel.querySelector('#tianyi-stat-videos'); const likeCounterEl = currentState.panel.querySelector('#tianyi-counter-like'); const collectCounterEl = currentState.panel.querySelector('#tianyi-counter-collect'); const shareCounterEl = currentState.panel.querySelector('#tianyi-counter-share'); const successRateEl = currentState.panel.querySelector('#tianyi-success-rate'); if (likesEl) likesEl.textContent = STATS.likes; if (collectsEl) collectsEl.textContent = STATS.collects; if (sharesEl) sharesEl.textContent = STATS.shares; if (videosEl) videosEl.textContent = STATS.videoCount; if (likeCounterEl) likeCounterEl.textContent = `${currentState.likeCounter}/${CONFIG.likeVideoMin}-${CONFIG.likeVideoMax}`; if (collectCounterEl) collectCounterEl.textContent = `${currentState.collectCounter}/${CONFIG.collectVideoMin}-${CONFIG.collectVideoMax}`; if (shareCounterEl) shareCounterEl.textContent = `${currentState.shareCounter}/${CONFIG.shareVideoMin}-${CONFIG.shareVideoMax}`; if (successRateEl) { const total = STATS.successes + STATS.failures; const rate = total > 0 ? Math.round((STATS.successes / total) * 100) : 0; successRateEl.textContent = `${rate}%`; } } } hideControlPanel() { if (currentState.panel) { currentState.panel.classList.add('tianyi-panel-hidden'); currentState.panelVisible = false; } } toggleControlPanel() { if (currentState.panelVisible) { this.hideControlPanel(); } else { this.showControlPanel(); } } makeDraggable(element) { let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0; const header = element.querySelector('.tianyi-panel-header') || element; header.style.cursor = 'move'; header.addEventListener('mousedown', dragMouseDown); function dragMouseDown(e) { e = e || window.event; e.preventDefault(); pos3 = e.clientX; pos4 = e.clientY; document.onmouseup = closeDragElement; document.onmousemove = elementDrag; } function elementDrag(e) { e = e || window.event; e.preventDefault(); pos1 = pos3 - e.clientX; pos2 = pos4 - e.clientY; pos3 = e.clientX; pos4 = e.clientY; element.style.top = (element.offsetTop - pos2) + "px"; element.style.left = (element.offsetLeft - pos1) + "px"; } function closeDragElement() { document.onmouseup = null; document.onmousemove = null; } } // ==================== 工具方法 ==================== getVideoElement() { return document.querySelector('video'); } simulateKeyPress(key) { const event = new KeyboardEvent('keydown', { key: key, code: `Key${key.toUpperCase()}`, keyCode: key.toUpperCase().charCodeAt(0), which: key.toUpperCase().charCodeAt(0), bubbles: true, cancelable: true }); document.dispatchEvent(event); } saveStats() { GM_setValue('likes', STATS.likes); GM_setValue('collects', STATS.collects); GM_setValue('shares', STATS.shares); GM_setValue('successes', STATS.successes); GM_setValue('failures', STATS.failures); GM_setValue('videoCount', STATS.videoCount); } showNotification(text, duration = 2000) { const notification = document.createElement('div'); notification.className = 'tianyi-notification'; notification.textContent = text; document.body.appendChild(notification); setTimeout(() => { if (notification.parentNode) { notification.parentNode.removeChild(notification); } }, duration); } showStats() { const statsText = ` 🚀 抖音助手统计 =============== 点赞次数: ${STATS.likes} 收藏次数: ${STATS.collects} 推荐次数: ${STATS.shares} 累计视频: ${STATS.videoCount} 成功次数: ${STATS.successes} 失败次数: ${STATS.failures} 成功率: ${STATS.successes + STATS.failures > 0 ? Math.round((STATS.successes / (STATS.successes + STATS.failures)) * 100) : 0}% =============== 执行规则: 点赞: 每 ${CONFIG.likeVideoMin}-${CONFIG.likeVideoMax} 个新视频 收藏: 每 ${CONFIG.collectVideoMin}-${CONFIG.collectVideoMax} 个新视频 推荐: 每 ${CONFIG.shareVideoMin}-${CONFIG.shareVideoMax} 个新视频 =============== 计数器状态: 点赞: ${currentState.likeCounter}/${CONFIG.likeVideoMin}-${CONFIG.likeVideoMax} 收藏: ${currentState.collectCounter}/${CONFIG.collectVideoMin}-${CONFIG.collectVideoMax} 推荐: ${currentState.shareCounter}/${CONFIG.shareVideoMin}-${CONFIG.shareVideoMax} `; alert(statsText); } resetStats() { if (confirm('确定要重置所有统计和计数器吗?')) { STATS.likes = 0; STATS.collects = 0; STATS.shares = 0; STATS.videoCount = 0; STATS.successes = 0; STATS.failures = 0; currentState.likeCounter = 0; currentState.collectCounter = 0; currentState.shareCounter = 0; this.saveStats(); this.updatePanelStats(); this.showNotification('📊 统计和计数器已重置'); } } } // 初始化脚本 let automation; function init() { if (!automation) { automation = new DouyinAutoHelper(); window.tianyiAutomation = automation; } } // 页面加载完成后初始化 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })();