Skip to content

Instantly share code, notes, and snippets.

@Iaotle
Forked from goto-dev-null/omegle.js
Last active July 6, 2023 06:03
Show Gist options
  • Save Iaotle/bc82aee8b23e5ca522db5472501e76a5 to your computer and use it in GitHub Desktop.
Save Iaotle/bc82aee8b23e5ca522db5472501e76a5 to your computer and use it in GitHub Desktop.
JS script to skip undesirables on omegle and auto-retry
var secondsToWait = 30;
var secondsWaited = 0;
var introMsg = "M24";
var chatText;
var resps;
var yourlines;
var strangerlines;
var chatStarted = false;
function skip(btn) {
clearInterval(timerId);
secondsWaited = 0;
setTimeout(() => { btn.click(); }, 500);
setTimeout(() => { btn.click(); }, 500 * 2);
setTimeout(() => { btn.click(); }, 500 * 3);
setTimeout(() => restart(), 500 * 3 + 1000);
}
function sendMessage(msg) {
document.getElementsByClassName('chatmsg')[0].value = msg;
document.getElementsByClassName('sendbtn')[0].click();
}
function parseChat() {
chatText = document.getElementsByClassName('logbox')[0].innerText.toLowerCase();
resps = chatText.split('\n\n');
yourlines = resps.filter(element => element.startsWith("you:"));
strangerlines = resps.filter(element => element.startsWith("stranger:"));
}
function check() {
console.log('waiting ' + secondsWaited + '/' + secondsToWait);
var btn = document.getElementsByClassName('disconnectbtn')[0];
if (btn.textContent.includes('New')) {
btn.click();
setTimeout(() => restart(), 1000);
} else {
// Situations where you just want to quit
if (strangerlines?.some(element => element.includes("xeno"))) {
sendMessage("fuck you xeno");
console.log("fuck xeno.");
skip(btn);
} else if (
strangerlines?.some(element => element.includes("this is a bot")) ||
strangerlines?.some(element => element.includes("bot sorry"))) {
console.log("bot, skipping");
sendMessage("fuck bots");
skip(btn);
} else if (strangerlines?.some(element => element.includes("yiff"))) {
skip(btn);
} else if (
strangerlines?.some(element => element.includes("selling")) ||
strangerlines?.some(element => element.includes("seliing")) ||
strangerlines?.some(element => element.includes("seiling")) ||
strangerlines?.some(element => element.includes("seiiing"))) {
console.log("seller encountered, skipping.");
sendMessage("fuck sellers");
skip(btn);
}
if (chatStarted) {
console.log('chat started, waiting for stranger to quit');
return;
}
parseChat();
// less reliable parsing that might result in accidental quits, we don't run these if conversation has started
// TODO: filter for 'hi' lines
if (strangerlines.length == 0) {
secondsWaited += 1;
if (secondsWaited >= secondsToWait) {
skip(btn);
}
} else if (
strangerlines.some(element => element.includes("stranger: m")) ||
strangerlines.filter(element => /\w+,? \d+ M$/i.test(element)).length || // filters out "Hey, 24 M" and similar
strangerlines.filter(element => /\w+,? M\d+$/i.test(element)).length || // filters out "Hey, 24 M" and similar
strangerlines.some(element => element.includes("stranger: hi m")) ||
strangerlines.some(element => element.includes("i'm will")) ||
strangerlines.some(element => element.includes("stranger: hey m"))) {
console.log("male encountered, skipping.");
skip(btn);
} else {
// stop();
chatStarted = true;
}
}
}
function restart() {
console.log('restarting');
chatStarted = false;
secondsWaited = 0;
parseChat();
if (chatText.includes("now chatting with")) {
if (yourlines.length == 0) {
sendMessage(introMsg);
}
clearInterval(timerId);
timerId = setInterval(check, 1000);
} else {
console.log('waiting to find user');
setTimeout(() => restart(), 1000);
}
}
var timerId = null
function start() {
console.log('starting');
clearInterval(timerId);
timerId = setInterval(check, 1000);
}
function stop() {
console.log('stopping');
clearInterval(timerId);
}
start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment