diff --git a/抖音/抖音直播自动下翻.js b/抖音/抖音直播自动下翻.js index 8c9c080..46c3b35 100644 --- a/抖音/抖音直播自动下翻.js +++ b/抖音/抖音直播自动下翻.js @@ -1,8 +1,8 @@ // ==UserScript== // @name 抖音直播自动下翻 (可见性检测版) // @namespace http://tampermonkey.net/ -// @version 1.4 -// @description 只有当“直播中”标签在屏幕上可见时,才触发自动翻页 +// @version 1.5 +// @description 只有当"直播中"标签在屏幕上可见时,才触发自动翻页;自动点击"继续播放"按钮 // @author Gemini // @match *://*.douyin.com/* // @grant none @@ -83,9 +83,34 @@ } }; - // --- 3. 监听 --- + // --- 3. 检测"长时间无操作"弹窗并自动点击继续播放 --- + const checkIdlePopup = () => { + // 查找"长时间无操作,已暂停播放"文本 + const xpath = "//div[contains(@class, 'Hr_mUoJc') and contains(text(), '长时间无操作')]"; + const idleElement = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; + + if (idleElement && isElementVisible(idleElement)) { + console.log('🔍 检测到"长时间无操作"弹窗'); + + // 查找"继续播放"按钮 + const buttonXpath = "//div[contains(@class, 'crGthr5B') and contains(text(), '继续播放')]"; + const continueButton = document.evaluate(buttonXpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; + + if (continueButton) { + console.log('✅ 找到"继续播放"按钮,准备点击'); + continueButton.click(); + console.log('🎬 已自动点击"继续播放"按钮'); + } else { + console.log('⚠️ 未找到"继续播放"按钮'); + } + } + }; + + // --- 4. 监听 --- // 抖音滑动比较快,我们结合 MutationObserver 和 高频轮询 确保不漏掉任何瞬间 setInterval(runDetection, 300); // 每 300ms 检查一次可见性 + setInterval(checkIdlePopup, 1000); // 每 1000ms 检查一次是否有"长时间无操作"弹窗 console.log('抖音直播可见性检测脚本注入成功'); + console.log('自动点击"继续播放"功能已启用'); })(); \ No newline at end of file