Script for omegle with automated features.
As of
// ==UserScript==
// @name Automated Omegle Script
// @namespace lazi3b0y
// @include http://*.omegle.com/*
// @version 2.5
// @grant GM_addStyle
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @description Script for omegle with automated features.
// @allow pasting
// ==/UserScript==
this.$ = this.jQuery = jQuery.noConflict(true);
GM_addStyle(
"td.chatmsgcell { width: 50%; }" +
"#omegle-greetings-text-in-chat { width: 100%; background: #FFF none repeat scroll 0% 0%; font-family: sans-serif; border: 0px none; padding: 0px; margin: 0px; height: 4.5em; font-size: 1em; overflow: auto; border-radius: 0px; resize: none; }" +
"#omegle-greetings-text-start { position: absolute; top: 105px; left: 5px; width: 245px; height: 475px; resize: none; border-radius: 5px; border: solid 1px #cccccc; padding: 6px 10px; font-family: sans-serif; }" +
".greetingsmsgcell { width: 50%; }" +
".greetingsmsgwrapper { background: #FFF none repeat scroll 0% 0%; border: 1px solid #CCC; height: 4.5em; padding: 0.25em; }" +
".script-checkbox-wrapper { position: absolute; line-height: 12px; padding: 2px; }" +
".auto-disconnect-checkbox-wrapper { position: absolute; line-height: 12px; padding: 2px; }" +
".activate-script-label { position: absolute; display: inline-block; font-size: 11px; }" +
".activate-auto-disconnect-label { position: absolute; display: inline-block; font-size: 11px; }" +
".auto-disconnect-timer { position: absolute; display: inline-block; font-size: 11px; top: 75px; right: 25px; }" +
".hide { display: none; }"
);
var aborts=[
'You have disconnected',
'Stranger has disconnected',
'Technical error: Server was unreachable for too long and your connection was lost.',
];
var timeout = 600; // Timeout value * 100 milliseconds. 600 = 1 minute.
var autoTextSent = false;
var customIntroDisplayed = false;
/***************************************************************************************
Variables that will be updated every cycle (100ms interval)
***************************************************************************************/
var introId;
var chatbox3Div;
var scriptCheckBox;
var autoDisconnectCheckBox;
var autoDisconnectTimerDiv;
var introAutoTextBox;
var chatAutoTextBox;
var scriptCheckBox;
var autoDisconnectCheckBox;
var timeRemaining;
var temp;
var autoText;
var chatMessages;
var disconnectTimer;
$('body').append('<textarea id="omegle-greetings-text-start" placeholder="Automated Hi goes here..." />');
$('body').append('<div class="auto-disconnect-timer hide"></div>');
$('body').append('<div class="script-checkbox-wrapper" style="top: 70px; left: 1px;">' +
'<input id="auto-omegle-enabled" type="checkbox" checked />' +
'</div>');
$('body').append('<div class="activate-script-label" style="top: 75px; left: 22px;">' +
'Activate auto script' +
'</div>');
$('body').append('<div class="auto-disconnect-checkbox-wrapper" style="top: 85px; left: 1px;">' +
'<input id="reconnect-omegle-enabled" type="checkbox" checked />' +
'</div>');
$('body').append('<div class="activate-auto-disconnect-label" style="top: 90px; left: 22px;">' +
'Activate auto disconnect' +
'</div>');
function disconnect() {
autoTextSent = false;
chatMessages = null;
disconnectTimer = 0;
$('button.disconnectbtn').click();
if ($( "body:containsIN('You're now chatting with a random stranger.')" ).text()) {
$('button.disconnectbtn').click();
}
}
function displayCustomIntro() {
var scriptCheckBoxWrapper = $('.script-checkbox-wrapper');
var scriptCheckBoxLabel = $('.activate-script-label');
var autoDisconnectCheckBoxWrapper = $('.auto-disconnect-checkbox-wrapper');
var autoDisconnectCheckBoxLabel = $('.activate-auto-disconnect-label');
var autoDisconnectTimerDiv = $('.auto-disconnect-timer');
var introAutoTextBox = $('#omegle-greetings-text-start');
var chatAutoTextBox = $('td.chatmsgcell');
introAutoTextBox.removeClass('hide');
chatAutoTextBox.remove();
scriptCheckBoxWrapper.css({ 'top': '70px', 'left': '1px' });
scriptCheckBoxLabel.css({ 'top': '75px', 'left': '22px' });
autoDisconnectCheckBoxWrapper.css({ 'top': '85px', 'left': '1px' });
autoDisconnectCheckBoxLabel.css({ 'top': '90px', 'left': '22px' });
$('#omegle-greetings-text-start').val(autoText);
autoDisconnectTimerDiv.addClass('hide');
customIntroDisplayed = true;
}
function displayCustomChat() {
var scriptCheckBoxWrapper = $('.script-checkbox-wrapper');
var scriptCheckBoxLabel = $('.activate-script-label');
var autoDisconnectCheckBoxWrapper = $('.auto-disconnect-checkbox-wrapper');
var autoDisconnectCheckBoxLabel = $('.activate-auto-disconnect-label');
var autoDisconnectTimerDiv = $('.auto-disconnect-timer');
var introAutoTextBox = $('#omegle-greetings-text-start');
var chatAutoTextBox = $('td.chatmsgcell');
introAutoTextBox.addClass('hide');
chatAutoTextBox.after('<td class="greetingsmsgcell">' +
'<div class="greetingsmsgwrapper">' +
'<textarea id="omegle-greetings-text-in-chat" placeholder="Automated Hi goes here..." />' +
'</div>' +
'</td>');
scriptCheckBoxWrapper.css({ 'top': '70px', 'left': '10px' });
scriptCheckBoxLabel.css({ 'top': '75px', 'left': '32px' });
autoDisconnectCheckBoxWrapper.css({ 'top': '70px', 'left': '153px' });
autoDisconnectCheckBoxLabel.css({ 'top': '75px', 'left': '175px' });
$('#omegle-greetings-text-in-chat').val(autoText);
autoDisconnectTimerDiv.removeClass('hide');
customIntroDisplayed = false;
}
$.extend($.expr[":"], {
"containsIN": function(elem, i, match, array) {
return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
}
});
setInterval(function() {
introId = $('#intro');
chatbox3Div = $('.chatbox3');
scriptCheckBox = $('#auto-omegle-enabled');
autoDisconnectCheckBox = $('#reconnect-omegle-enabled');
autoDisconnectTimerDiv = $('.auto-disconnect-timer');
introAutoTextBox = $('#omegle-greetings-text-start');
chatAutoTextBox = $('#omegle-greetings-text-in-chat');
scriptCheckBox = $('#auto-omegle-enabled');
autoDisconnectCheckBox = $('#reconnect-omegle-enabled');
timeRemaining = Math.round((timeout - disconnectTimer) / 10);
temp = $('.logbox > div').children().length;
/****************************************************************
Depending on what is present inside the body
(either the id 'intro' or the div 'chatbox3') either
the custom ui for the startpage, or the ui for
when chatting and looking for strangers, is
displayed.
****************************************************************/
if (introId.length && !customIntroDisplayed) {
displayCustomIntro();
return;
} else if (chatbox3Div.length && !$('#omegle-greetings-text-in-chat').length){
displayCustomChat();
}
/****************************************************************
Update the automatic disconnect timer. If the
checkbox for enabling automatic disconnection
is unchecked 'Auto disconnect is disabled' will be
printed in its stead.
****************************************************************/
autoDisconnectTimerDiv.text(function() {
if (autoDisconnectCheckBox[0].checked) {
return 'Auto disconnecting from Stranger in ' + timeRemaining + 's';
} else {
return 'Auto disconnect is disabled';
}
});
/****************************************************************
Save whatever has been typed into either the
textarea on the intro page or the one when
chatting, so that it can be used later.
****************************************************************/
if (introAutoTextBox.length) {
autoText = introAutoTextBox.val();
} else if (chatAutoTextBox.length) {
autoText = chatAutoTextBox.val();
}
/****************************************************************
If the checkbox for automated functions is
unticked, connecting to the server, looking
for a new stranger or on the startpage then
return.
Else if the timer has counted down too 0 then
disconnect from the current stranger and then
return.
****************************************************************/
if (!scriptCheckBox[0].checked || $( 'body:containsIN("Connecting to server")' ).text() || $( 'body:containsIN("Looking for someone you can chat with")' ).text() || introId.length) {
return;
}
else if (disconnectTimer == timeout && autoDisconnectCheckBox[0].checked) {
disconnect();
return;
}
/****************************************************************
If any of the strings inside the array is
present inside the body then disconnect
and return.
****************************************************************/
$(aborts).each(function() {
if ($( 'body:containsIN("' + this + '")' ).text()){
disconnect();
return;
}
});
/****************************************************************
If the automated Hi-message hasn't been sent
yet and a new stranger has been found then
send the automated Hi-message.
****************************************************************/
if (autoTextSent == false && $( "body:containsIN('You're now chatting with a random stranger.')" ).text() ) {
$('textarea.chatmsg').val(autoText);
$('button.sendbtn').click();
autoTextSent = true;
}
/****************************************************************
If the automated Hi-message hasn't been sent
yet and a new stranger has been found then
send the automated Hi-message.
****************************************************************/
if (!chatMessages || chatMessages != temp) {
chatMessages = $('.logbox > div').children().length;
disconnectTimer = 0;
}
else if (autoDisconnectCheckBox[0].checked) {
disconnectTimer += 1;
}
}, 100); //Run this function every 100ms