From e11372bdab1a62308884b5fa71ec7beed503839d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=99=BD=E7=8C=BF?= <1083092844@qq.com> Date: Thu, 17 Aug 2023 20:33:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B4=E6=92=AD=E9=A1=B5=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E6=B3=A8=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BarrageGrab/Scripts/inject/livePage.js | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 BarrageGrab/Scripts/inject/livePage.js diff --git a/BarrageGrab/Scripts/inject/livePage.js b/BarrageGrab/Scripts/inject/livePage.js new file mode 100644 index 0000000..68d23e2 --- /dev/null +++ b/BarrageGrab/Scripts/inject/livePage.js @@ -0,0 +1,37 @@ +//上下文常量将在上方由程序注入 +//const PROCESS_NAME = "进程名"; + +/** + * Web/PC端 直播页JS注入 + * 正则: @".*:\/\/live.douyin\.com\/\d+" + **/ + +/*注入脚本 定时触发全局keydown,避免直播流被无操作阻断*/ + +// 创建一个虚拟的按键事件 +const simulatedEvent = new KeyboardEvent('keydown', { + key: 'Virtual_Alt', + keyCode: 18, //alt + bubbles: true, + cancelable: true +}); + +// 获取要分派事件的目标元素,例如文档的根元素 +const targetElement = document.documentElement; + +// 设置定时器,每隔60秒模拟一次按键事件 +setInterval(() => { + targetElement.dispatchEvent(simulatedEvent); +}, 1000 * 60); + +// 订阅 keydown 事件 (Debug) +targetElement.addEventListener('keydown', event => { + if (event.key == "Virtual_Alt") { + console.log('[防挂机处理] 按下了', event.key); + } +}); + +/*禁止关闭 Websocket*/ +WebSocket.prototype.close = function () { return; } + +