// ==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 `