Compare commits
2 Commits
90f9949e61
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0828b85736 | ||
|
|
4315f48786 |
12
README.md
12
README.md
@@ -1,3 +1,13 @@
|
||||
# Tampermonkey_Scripts
|
||||
|
||||
油猴脚本
|
||||
这个仓库主要用于分享一些自用的油猴脚本。
|
||||
|
||||
## 脚本列表
|
||||
|
||||
- **抖音直播自动下翻** - 自动控制抖音直播间内容下翻功能
|
||||
|
||||
## 使用说明
|
||||
|
||||
1. 安装 [Tampermonkey](https://www.tampermonkey.net/) 浏览器扩展
|
||||
2. 选择需要的脚本并安装
|
||||
3. 访问对应网站即可自动运行
|
||||
@@ -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('自动点击"继续播放"功能已启用');
|
||||
})();
|
||||
Reference in New Issue
Block a user