From 0828b857362f86c3e94b6cc67bb788120e5ece4b Mon Sep 17 00:00:00 2001 From: DCRClub Date: Thu, 15 Jan 2026 22:10:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8A=96=E9=9F=B3=E7=9B=B4?= =?UTF-8?q?=E6=92=AD=E8=87=AA=E5=8A=A8=E4=B8=8B=E7=BF=BB=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E5=8D=87=E5=8F=AF=E8=A7=81=E6=80=A7=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E5=8A=9F=E8=83=BD=E5=B9=B6=E6=B7=BB=E5=8A=A0=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E7=82=B9=E5=87=BB"=E7=BB=A7=E7=BB=AD=E6=92=AD?= =?UTF-8?q?=E6=94=BE"=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 抖音/抖音直播自动下翻.js | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) 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