Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Official Blog
  • Nearby Places Finder
  • Direction Route Finder
  • Distance & Time Calculator
Menu

Javascript Project to Build Omegle Bot & Automate it in Browser Using Bootstrap 4 For Beginners

Posted on October 2, 2022

 

 

Welcome folks today in this blog post we will be building a omegle bot in javascript using bootstrap 4. All the full source code of the application is shown below.

 

 

Omegle Bot Source Code

 

 

JavaScript
1
2
3
4
5
6
7
8
9
10
function executeOmegle()
    {
      let btn = document.querySelector('.disconnectbtn')
      let messageBox = document.querySelector('.chatmsg')
      let sendBtn = document.querySelector('.sendbtn')
      btn.click()
      messageBox.innerHTML="This is the message for the bot"
      sendBtn.click()
    }
    setInterval(executeOmegle,2000)

 

 

Here in this above javascript function of the omegle bot we have different variables which are as follows

 

Message of the bot: Here we are assigning the static message of the bot which is “This is the message for the bot”

 

Delay of the bot: This is the delay of the bot which is in milliseconds

 

 

Usage

 

 

Now to use this omegle bot javascript function we need to go to developer tools of the chrome browser. And then go to the console and copy paste this function as shown below

 

First of all we need to right click and go to inspect element

 

 

 

 

And now you need to go to console menu and copy paste this above function as shown below

 

 

 

 

Get Started

 

 

In order to get started you need to make an index.html file and copy paste the below code

 

 

index.html

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html lang="en">
 
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Omegle Bot Code Generator in Javascript</title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
</head>
<body>
</body>
</html>

 

 

In the first step we are including the bootstrap cdn and we have given the title omegle bot code generator

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<div class="container">
    <h1 class="text-center">
      Omegle Bot Generator in Javascript
    </h1>
    <form id="form">
      <div class="form-group">
        <label for="message">Enter Message For Bot:</label>
        <textarea id="message" rows="10" cols="20" placeholder="Enter Message" type="text" class="form-control"></textarea>
      </div>
      <div class="form-group">
        <label for="delay">Enter Delay For Bot: (In MilliSeconds)</label>
        <input id="delay" placeholder="Enter Delay in Seconds" value="2000" type="number" class="form-control" />
      </div>
      <div class="form-group">
        <button class="btn btn-primary btn-block">Get Source Code</button>
      </div>
    </form>
    <div class="form-group">
      <label for="result">Source Code For Bot:</label>
      <textarea class="form-control" name="" id="result" readonly cols="30" rows="10"></textarea>
    </div>
  </div>

 

 

And now in the next step you can see we are adding the bootstrap textarea field where the user will write the message for the omegle bot and also a input field which will hold the value for the omegle bot delay. And then we have the button to generate the source code of the omegle bot. And then we have the resultant textarea where we will hold the source code.

 

 

 

 

And now we will write the javascript code where we will get the references to the textarea and the input field as shown below

 

 

JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
let form = document.getElementById('form')
 
  form.addEventListener('submit', (e) => {
    e.preventDefault()
    let message = document.getElementById('message').value
    let delay = document.getElementById('delay').value
    let sourceCode = getSourceCode(message, delay)
 
    let result = document.getElementById('result')
 
    result.innerHTML = sourceCode
  })

 

 

Here we are attaching the submit event handler to the form element inside this we are getting the values of the textarea and the input field. And then we are calling a special function getSourceCode() function which we will make in the next step which will return the javascript source code for the omegle bot. And then we are getting the reference of the resultant textarea. And lastly we are attaching the source code to the textarea.

 

 

JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function getSourceCode(message, delay) {
    return `
    function executeOmegle()
    {
      let btn = document.querySelector('.disconnectbtn')
      let messageBox = document.querySelector('.chatmsg')
      let sendBtn = document.querySelector('.sendbtn')
      btn.click()
      messageBox.innerHTML="${message}"
      sendBtn.click()
    }
    setInterval(executeOmegle,${delay})
    `
  }

 

 

And here in this block of code we are returning the javascript function for the omegle bot and here we are replacing the dynamic message and the delay of the bot inside this function.

 

 

Full Example Code

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html lang="en">
 
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Omegle Bot Code Generator in Javascript</title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
</head>
 
<body>
  <div class="container">
    <h1 class="text-center">
      Omegle Bot Generator in Javascript
    </h1>
    <form id="form">
      <div class="form-group">
        <label for="message">Enter Message For Bot:</label>
        <textarea id="message" rows="10" cols="20" placeholder="Enter Message" type="text" class="form-control"></textarea>
      </div>
      <div class="form-group">
        <label for="delay">Enter Delay For Bot: (In MilliSeconds)</label>
        <input id="delay" placeholder="Enter Delay in Seconds" value="2000" type="number" class="form-control" />
      </div>
      <div class="form-group">
        <button class="btn btn-primary btn-block">Get Source Code</button>
      </div>
    </form>
    <div class="form-group">
      <label for="result">Source Code For Bot:</label>
      <textarea class="form-control" name="" id="result" readonly cols="30" rows="10"></textarea>
    </div>
  </div>
</body>
<script>
  let form = document.getElementById('form')
 
  form.addEventListener('submit', (e) => {
    e.preventDefault()
    let message = document.getElementById('message').value
    let delay = document.getElementById('delay').value
    let sourceCode = getSourceCode(message, delay)
 
    let result = document.getElementById('result')
 
    result.innerHTML = sourceCode
  })
 
  function getSourceCode(message, delay) {
    return `
    function executeOmegle()
    {
      let btn = document.querySelector('.disconnectbtn')
      let messageBox = document.querySelector('.chatmsg')
      let sendBtn = document.querySelector('.sendbtn')
      btn.click()
      messageBox.innerHTML="${message}"
      sendBtn.click()
    }
    setInterval(executeOmegle,${delay})
    `
  }
</script>
 
</html>

 

 

Recent Posts

  • Angular 14/15 JWT Login & Registration Auth System in Node.js & Express Using MongoDB in Browser
  • Build a JWT Login & Registration Auth System in Node.js & Express Using MongoDB in Browser
  • React-Admin Example to Create CRUD REST API Using JSON-Server Library in Browser Using Javascript
  • Javascript Papaparse Example to Parse CSV Files and Export to JSON File and Download it as Attachment
  • Javascript Select2.js Example to Display Single & Multi-Select Dropdown & Fetch Remote Data Using Ajax in Dropdown
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • java
  • javascript
  • Koajs
  • kotlin
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • ReactNative
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme