You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Omegle JavaScript机器人修改后仅发送第一条消息的问题求助

Omegle机器人发送两条消息仅第一条生效的问题解决

问题背景

我将原本仅发送单条消息的Omegle JavaScript机器人修改为发送两条消息,但在开发者控制台运行修改后的代码时,仅第一条消息能成功发送,第二条消息无法发送。

原单条消息代码

function executeOmegle()
{
    let btn = document.querySelector('.disconnectbtn')
    let messageBox = document.querySelector('.chatmsg')
    let sendBtn = document.querySelector('.sendbtn')
    btn.click()
    messageBox.innerHTML="Hello, how are you? To know about me visit codermen.com."
    sendBtn.click()
}

setInterval(executeOmegle,4000)

修改后的代码(期望发送两条但仅第一条生效)

function executeOmegle()
{
    let btn = document.querySelector('.disconnectbtn')
    let messageBox = document.querySelector('.chatmsg')
    let sendBtn = document.querySelector('.sendbtn')
    btn.click()
    messageBox.innerHTML="Hello, this is the first message"
    sendBtn.click()
    messageBox.innerHTML="Hello, this is the second message - the one that doesnt send."
    sendBtn.click()
}

setInterval(executeOmegle,4000)

问题原因

  • 发送按钮点击后会短暂处于不可用状态,连续快速点击会导致第二条点击被前端忽略,因为此时按钮还未恢复可点击状态。
  • 直接修改innerHTML未触发Omegle消息框的输入事件监听,页面未识别到消息内容已更新,导致第二条发送操作无效。

解决方案

1. 添加发送延迟

通过setTimeout给两条消息的发送流程添加间隔,让页面有足够时间完成第一条消息的发送状态更新:

function executeOmegle()
{
    let btn = document.querySelector('.disconnectbtn')
    let messageBox = document.querySelector('.chatmsg')
    let sendBtn = document.querySelector('.sendbtn')
    btn.click()

    // 发送第一条消息
    messageBox.innerHTML = "Hello, this is the first message"
    sendBtn.click()

    // 延迟500ms发送第二条,可根据网络情况调整时长
    setTimeout(() => {
        messageBox.innerHTML = "Hello, this is the second message - now it works."
        sendBtn.click()
    }, 500)
}

setInterval(executeOmegle, 4000)

2. 模拟真实输入事件(更稳定)

改用模拟用户输入的方式,触发消息框的input事件,确保页面正确识别内容变化:

// 封装设置消息并触发输入事件的函数
function setChatMessage(inputElement, text) {
    inputElement.value = text;
    inputElement.dispatchEvent(new Event('input', { bubbles: true }));
}

function executeOmegle()
{
    let btn = document.querySelector('.disconnectbtn')
    let messageBox = document.querySelector('.chatmsg')
    let sendBtn = document.querySelector('.sendbtn')
    btn.click()

    // 发送第一条消息
    setChatMessage(messageBox, "Hello, this is the first message")
    sendBtn.click()

    // 延迟发送第二条
    setTimeout(() => {
        setChatMessage(messageBox, "Hello, this is the second message - now it works.")
        sendBtn.click()
    }, 500)
}

setInterval(executeOmegle, 4000)

注意:延迟时长可根据实际网络情况调整(比如1000ms),同时Omegle存在反机器人机制,频繁自动发送消息可能导致账号受限,请谨慎使用。

内容的提问来源于stack exchange,提问作者Bejamino G

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 08:22:47