You are on page 1of 13

// ==UserScript==

// @name auto owo full discord new


// @namespace discord
// @version 1.0
// @description try to take over the world!
// @author iz
// @match https://discord.com/channels/*
// @icon https://www.google.com/s2/favicons?domain=discord.
// @resource draggabilly
https://cdn.bootcdn.net/ajax/libs/draggabilly/2.3.0/draggabilly.pkgd.min.js
// @resource sweetalert2 https://cdnjs.cloudflare.com/ajax/libs/limonte-
sweetalert2/10.16.6/sweetalert2.all.min.js
// @grant GM_getResourceText
// @grant GM_xmlhttpRequest
// @grant GM_openInTab
// @grant unsafeWindow
// @run-at document-start
// @connect 2captcha.com
// ==/UserScript==

const document = unsafeWindow.document;


const setTimeout = unsafeWindow.setTimeout;
const setInterval = unsafeWindow.setInterval;
const clearInterval = unsafeWindow.clearInterval;
//window.console = unsafeWindow.console;
const console_log = unsafeWindow.console.log;
window.console.log = function(){
console_log(`%c[OwO] %c${(new Date()).toLocaleString("vi-VN")}:`, "color: red",
"color: unset", ...arguments);
}

const USER_NAME = "Zer0"; // user name của bạn


const BOT_NAME = "OwO";
const CHANNEL_ID_CHAT_WITH_BOT = "805675467901370419"; // channel ID của bạn và bot
const CHANNEL_ID_PLAY = "928271229390028810"; // channel ID đang chơi
const OWO_AUTO_HUNT = "owo hb 100";
const OWO_CMD_PRAY = "owo pray <@!805673450085417031>"; // lấy id user bằng cách mở
devtool gõ searchIdByUserName("User name")
// Dùng generateFuncRandom để tạo random thời gian. Tính bằng giây. Hoặc ghi số
giây cũng đc.
const COMMANDS = [
["owo", generateFuncRandom(1, 5)],
["owo b", generateFuncRandom(1, 3)],
["owo h", generateFuncRandom(12, 16)]

];
const DELTA_TIME_IF_NOT_CAPTCHA = 15*60; // Khoảng thời gian nếu ko gặp captcha để
kích hoạt thời gian ngủ bên dưới. Tính bằng giây
const SLEEP_TIME_IF_NOT_CAPTCHA = 0*60; // Thời gian ngủ nếu ko gặp catcha. Tính
bằng giây

const API_KEY_2CAPTCHA = "b5f8ca7d2902a187c92c46efbc6c33e3"; // 2captcha KEY


const MAX_RETRIES_REQUEST_2CAPTCHA = 10; // Số lần thử nếu gọi đến api 2captcha bị
lỗi
const MAX_RETRIES_GET_RESPONSE_2CAPTCHA = 10; // Số lần thử lấy text từ 2captcha
const TYPE_WAIT_NEXT = 0;
const TYPE_WRONG_PASS = 1;
var resolve_captcha_done = true;// mac dinh moi vo la giai dc captcha roi
var run_resolve_captcha_autohunt = true;
var resolve_captcha_autohunt = false;
var users_store = {};
unsafeWindow.users_store = users_store;

function getIdByUserName(user_name){
return users_store[user_name]?.id;
}

function searchIdByUserName(user_name){
if(!user_name) return null;
for(let key in users_store){
if(key.includes(user_name)){
return users_store[key]?.id;
}
}
return null;
}

unsafeWindow.getIdByUserName = getIdByUserName;
unsafeWindow.searchIdByUserName = searchIdByUserName;

function generateFuncRandom(min, max){


return function(){
return Math.floor(Math.random() * (max - min + 1) ) + min;;
}
}

function $(selector, node = document){


return node.querySelector(selector);
}

function $ALL(selector, node = document){


return node.querySelectorAll(selector);
}

Object.assign($, {
create: function(tag, attrs = {}){
let elem = document.createElement(tag);
Object.assign(elem, attrs);
if(attrs.appendBody){
document.body.appendChild(elem);
}
if(attrs.appendHead){
document.head.appendChild(elem);
}
return elem;
},
ready: function(callback){
document.addEventListener("DOMContentLoaded", callback);
},
addStyle: function(source){
if(source.startsWith("http") || source.startsWith("blob:")){
$.create("link", {
rel: "stylesheet",
href: source,
appendHead: true,
});
}else{
$.create("style", {
innerText: source,
type: "text/css",
appendHead: true,
});
}
}
});

function intercept_localStorage_getItem(){
// discord delete native localStorage, we should backup it
unsafeWindow._localStorage = unsafeWindow.localStorage;
unsafeWindow._localStorage.__proto__._getItem =
unsafeWindow._localStorage.__proto__.getItem;
unsafeWindow._localStorage.__proto__.getItem = function(key){
let value = this._getItem(key);
if (key === "token" && value){
try{
unsafeWindow.discord_token = JSON.parse(value);
}catch(e){
unsafeWindow.discord_token = "";
alert("Không tìm thấy token. Vui lòng không chạy code");
}
}
return value;
}
}

if(!unsafeWindow.has_intercept_localStorage){
intercept_localStorage_getItem();
unsafeWindow.has_intercept_localStorage = true;
}

function intercept_websocket_decode(){
Object.defineProperty(Object.prototype, "onData", {
set: function(value){
if (this.constructor.toString().includes("inflateGetHeader")){
this._onData = function(){
if(arguments.length){
// console.log("data:", arguments[0], typeof arguments[0]);
unsafeWindow.dispatchEvent(new
CustomEvent("discordMessage", {detail: {message: arguments[0]}}));
}
return value.apply(this, arguments);
}
}else{
this._onData = value;
}
},
get: function(){
return this._onData;
}
},
{
configurable: true,
writable: false,
});
}
if(!unsafeWindow.has_intercept_websocket){
intercept_websocket_decode();
unsafeWindow.has_intercept_websocket = true;
}

function send_discord(text){
let text_node = $("span[data-slate-zero-width]");
if(text_node) text_node.textContent = text;
setTimeout(function(){
let text_area_node = $("div.slateTextArea-1Mkdgw");
if (text_area_node){
text_area_node.dispatchEvent(new Event('input', { bubbles: true}));
for(let i = 0; i < 2; ++i){
setTimeout(function(){
text_area_node.dispatchEvent(new KeyboardEvent("keydown", {
bubbles:true,
key: "Enter",
keyCode: 13,
which: 13,
shiftKey: false,
ctrlKey: false,
metaKey: false
}))
}, 500);
}
}
}, 100);
}

async function send_native_message_discord(text, channel){


let discord_token = unsafeWindow.discord_token;
if(!discord_token) return;
let url = `${location.protocol}${unsafeWindow.GLOBAL_ENV.API_ENDPOINT}/v$
{unsafeWindow.GLOBAL_ENV.API_VERSION}/channels/${channel}/messages`;
const DISCORD_EPOCH = 14200704e5;
let nonce = Date.now()-DISCORD_EPOCH;
nonce = nonce <= 0 ? "0": (BigInt(nonce) << BigInt(22)).toString();
return await fetch(url, {
method: "POST",
cache: "no-cache",
headers: {
"Content-Type": "application/json",
"Authorization": discord_token
},
body: `{"content":"${text}","nonce":"${nonce}","tts":false}`
});
}

async function send_typing(channel_id){


let discord_token = unsafeWindow.discord_token;
if(!discord_token) return;
let url = `${location.protocol}${unsafeWindow.GLOBAL_ENV.API_ENDPOINT}/v$
{unsafeWindow.GLOBAL_ENV.API_VERSION}/channels/${channel_id}/typing`;
await fetch(url, {method: "POST", cache: "no-cache", headers: {"Authorization":
discord_token},body: null});
}

unsafeWindow.send_typing = send_typing;
async function sendRequest(url, method = "GET", data = null){
console.log("request send", method, url);
return new Promise(function(resolve, reject){
GM_xmlhttpRequest({
method: method,
url: url,
data: data,
onload: function(response) {
resolve(response);
},
onerror: function(resp){
console.log("GM_xmlhttpRequest", resp);
let error = resp.statusText || "There are some error";
reject(`HTTP ${resp.status}: ${error}`);
},
ontimeout: function(){
reject("Connect server timeout");
}
});
})
}

async function sleep(time){


return new Promise(function(resolve, reject){
setTimeout(resolve, time);
})
}

async function getTextFrom2Captcha(next_id, retries){


for(let i = 0; i < retries; ++i){
let response = await sendRequest("http://2captcha.com/res.php?key=" +
API_KEY_2CAPTCHA + "&action=get&id=" + next_id);
let responseText = response.responseText;
if(responseText === "CAPCHA_NOT_READY"){
await sleep(20000);
continue;
}else{
let tmp = responseText.split("|");
if(tmp?.length && tmp[0] === "OK"){
return tmp[1];
}else{
throw new Error("Server 2captcha error: " + responseText);
}
}
}
throw new Error(`Vượt quá ${retries} lần thử lấy kết quả từ 2captcha`);
}

async function sendImg2ResolveCaptchaService(data){


let response = await sendRequest("http://2captcha.com/in.php", "POST", data);
let responseText = response.responseText;
let tmp = responseText.split("|");
if(tmp?.length && tmp[0] === "OK"){
return tmp[1];
}else{
throw new Error("Server 2captcha error: " + responseText);
}
}
async function handle2Captcha(url_img){
let resp = await fetch(url_img);
if(!resp.ok){
throw new Error(`HTTP ${resp.status}: ${resp.statusText}`)
}
let blob = await resp.blob();
let form_data = new FormData();
form_data.append("method", "post");
form_data.append("key", API_KEY_2CAPTCHA);
form_data.append("file", blob);
let next_id = await sendImg2ResolveCaptchaService(form_data);
return await getTextFrom2Captcha(next_id, MAX_RETRIES_GET_RESPONSE_2CAPTCHA);
}

var command_index = 0;

function getNextCommand(){
command_index = command_index % COMMANDS.length;
let [command, time] = COMMANDS[command_index];
let time_sleep = typeof time === "function" ? time() : time;
++command_index;
return [command, time_sleep];
}

var isRun = false;


var autoSend_running = false;
var catch_captcha = 0;
async function autoSend(){
// Tránh tình trạng bị gọi nhiều lần khi vẫn còn đang chạy autoSend
if(autoSend_running) return;
autoSend_running = true;
// tính toán hạn chót khi ko gặp captcha
let deadline = Date.now() + DELTA_TIME_IF_NOT_CAPTCHA*1000;
catch_captcha = 0;
while(isRun){
let [command, time_sleep] = getNextCommand();
// tính toán lại hạn chót khi ko gặp captcha
if(catch_captcha !== 0){
deadline = Date.now() + DELTA_TIME_IF_NOT_CAPTCHA*1000;
catch_captcha = 0;
}else if(Date.now() >= deadline){
// gán thời gian ngủ và tính hạn chót mới
time_sleep = SLEEP_TIME_IF_NOT_CAPTCHA;
deadline = Date.now() + (DELTA_TIME_IF_NOT_CAPTCHA +
SLEEP_TIME_IF_NOT_CAPTCHA)*1000;
}
if(!resolve_captcha_done) continue;
await send_native_message_discord(command, CHANNEL_ID_PLAY);
// console.log(`CMD "${command}" sleep ${time_sleep}s`);
// console.log(`Deadline ${(new Date(deadline)).toLocaleString("vi-VN")}`);
// console.log(`Sleep to ${(new Date(Date.now()
+time_sleep*1000)).toLocaleString("vi-VN")}`);
await sleep(time_sleep*1000);
}
autoSend_running = false;
}

function btn_onChange(){
let elem = $("div#btn-auto-owo");
console.log("toggle", isRun);
if(isRun){
isRun = false;
elem.textContent = "Start";
return;
}else{
isRun = true;
resolve_captcha_done = true;
elem.textContent = "Stop";
autoSend();
}
}

function start_auto_send(){
isRun = false;
btn_onChange();
}

function stop_auto_send(){
isRun = true;
btn_onChange();
}

async function sendTextCaptcha2OwOBotChannel(url_img){


let retries = 1;
let last_error = null;
while(!resolve_captcha_done){
try{
let text_captcha = await handle2Captcha(url_img);
await send_native_message_discord(text_captcha,
CHANNEL_ID_CHAT_WITH_BOT);
return;
}catch(err){
last_error = err;
}
if (retries >= MAX_RETRIES_REQUEST_2CAPTCHA){
Swal.fire({
icon: "error",
title: "Lỗi",
text: last_error
});
return;
}
++retries;
await sleep(5000);
}
}

function calculateTimeResetCaptchaPassword(content){
let matches = content.match(/Password will reset in (\d+) minutes/);
if (matches?.length){
let min = parseInt(matches[1]);
let deadline = Date.now() + (min*60+5)*1000;
return deadline;
}
throw new Error("Không tìm thấy đúng định dạng thời gian Password reset");
}

function calculateDeadline(content){
let matches = content.match(/BACK IN (?:(\d+)?H)?(\d+)M WITH/);
if (matches?.length){
let hour = 0;
if (matches[1]){
hour = parseInt(matches[1]);
}
let min = parseInt(matches[2]);
let deadline = Date.now() + (hour*3600+min*60+10)*1000;
return deadline;
}
throw new Error("Không tìm thấy đúng định dạng thời gian");
}

async function waitForNextAutoHunt(deadline, type=TYPE_WAIT_NEXT){


while(true){
if(type === TYPE_WRONG_PASS && resolve_captcha_autohunt){
return;
}
if(resolve_captcha_done && Date.now() >= deadline){
await send_native_message_discord("owo hb", CHANNEL_ID_PLAY);
await sleep(5000);
await send_native_message_discord(OWO_AUTO_HUNT, CHANNEL_ID_PLAY);
return;
}
await sleep(10000);
}
}

async function sendCMDAutoHuntWithCaptcha(url_img){


// Thử chạy MAX_RETRIES_REQUEST_2CAPTCHA lần nếu gặp lỗi gọi đến api 2captcha
let retries = 1;
let last_error = null;
while(run_resolve_captcha_autohunt){
try{
let text_captcha = await handle2Captcha(url_img);
text_captcha = text_captcha.replaceAll("5", "s");
text_captcha = text_captcha.replaceAll("2", "e");
await send_native_message_discord(`${OWO_AUTO_HUNT} ${text_captcha}`,
CHANNEL_ID_PLAY);
run_resolve_captcha_autohunt = false;
return;
}catch(err){
console.log(err);
last_error = err;
}
if (retries >= MAX_RETRIES_REQUEST_2CAPTCHA){
Swal.fire({
icon: "error",
title: "Lỗi",
text: last_error
});
return;
}
++retries;
await sleep(5000);
}
}

async function sendCmdPray(channel_id){


await sleep(10000);
while(true){
if(resolve_captcha_done){
await send_native_message_discord(OWO_CMD_PRAY, channel_id);
return;
}
await sleep(10000);
}
}

function add_user_store(new_user){
const username = new_user.username;
const user = users_store[username];
if(!user){
users_store[username] = new_user;
}else{
users_store[username] = {...user, ...new_user};
}
}

function save_user(message){
const t = message?.t;
const d = message?.d;
if(t === "READY" && d?.users?.length){
let users = message.d.users;
users.forEach(add_user_store);
}else if(t === "GUILD_MEMBER_LIST_UPDATE" && d?.ops?.length){
if(!Array.isArray(d.ops)) return;
for(let op of d.ops){
if(!Array.isArray(op.items)) continue;
for(let item of op.items){
if(item.member?.user){
add_user_store(item.member.user);
}
}
}
}
}

// Beep Boop. Are you a real human? Please reply with the following 5 letter word
so I can check!
// user_name**, Beep Boop. Please DM me with only the following 5 letter word to
check that you are a human!
unsafeWindow.addEventListener("discordMessage", function(event){
let message = event.detail.message;
//console.log("message:", message);
try{
message = JSON.parse(message);
}catch(e){
console.error("Json parse error", e);
//console.log("message:", message);
return;
}
save_user(message);
if(message?.t == "MESSAGE_CREATE" && message.d?.content){
let content = message.d.content;
let channel_id = message.d.channel_id;

if(message.d.author?.username.includes("reaction bot") &&


content.includes(`${USER_NAME}**, **pray/curse`)){
sendCmdPray(channel_id);
return;
}

if (message.d.author?.username === BOT_NAME){

if ((channel_id === CHANNEL_ID_CHAT_WITH_BOT && content.includes("you a


real human")) ||
(channel_id !== CHANNEL_ID_CHAT_WITH_BOT &&
content.includes(USER_NAME) && content.includes("you are a human"))){
resolve_captcha_done = false;// Neu dinh captcha danh dau la chua
giai đc
++catch_captcha;

// Chú thích dòng này lại nếu không muốn dùng owo h, owo b
//
**********************************************************************
stop_auto_send();
if (message.d.attachments.length && message.d.attachments[0].url){
sendTextCaptcha2OwOBotChannel(message.d.attachments[0].url);
return;
}
let m = content.match(/(http:\/\/verify.owobot.com\/[0-9a-f]{8}-[0-
9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})/g);
//console.log("match", m);
if(m){
GM_openInTab(m[0], {active: true});
//window.open(m[0]);
}else{
Swal.fire({
icon: "error",
title: "Lỗi",
text: "Không phân tích được url verify"
});
}
//
**********************************************************************
return;
}

if(channel_id === CHANNEL_ID_PLAY && content.includes(USER_NAME)){

// Xử lý giải captcha và gửi lệnh owo autohunt + captcha


if(content.includes("is your password") &&
message.d.attachments[0].url){
run_resolve_captcha_autohunt = true;
resolve_captcha_autohunt = false;
console.log("owo auto hunt detect captcha",
message.d.attachments[0].url);
sendCMDAutoHuntWithCaptcha(message.d.attachments[0].url);
return;
}

// Xử lý password reset nếu giải sai captcha


if(content.includes("Wrong password") && content.includes("owo
autohunt")){
run_resolve_captcha_autohunt = false;
resolve_captcha_autohunt = false;
try{

waitForNextAutoHunt(calculateTimeResetCaptchaPassword(content), TYPE_WRONG_PASS);
}catch(err){
Swal.fire({
icon: "error",
title: "Lỗi",
text: err
});
}
return;
}

// Xử lý thời gian chờ và gửi lại owo hb


if(content.includes("WILL BE BACK IN")){
try{
run_resolve_captcha_autohunt = false;
resolve_captcha_autohunt = true;
waitForNextAutoHunt(calculateDeadline(content));
}catch(err){
Swal.fire({
icon: "error",
title: "Lỗi",
text: err
});
}
return;
}
}

// kiem tra giai đc captcha chua


if(channel_id === CHANNEL_ID_CHAT_WITH_BOT){
if(content.includes("verified that you are human")){
resolve_captcha_done = true; // ok đanh dau la giai dc
// Chú thích dòng này lại nếu không muốn dùng owo h, owo b
// *****************************
start_auto_send();
// *****************************
}else if(content.includes("Wrong verification code")){
Swal.fire({
icon: "error",
title: "Lỗi",
text: "Giải captcha sai"
});
}
}
}
}
});

function setupButtonDl(){
let elem = $.create("div", {
id: "auto-owo-container",
innerHTML: `<div class="auto-owo-title">
<span>Auto owo</span>
</div>
<div id="btn-auto-owo">Start</div>`,
appendBody: true
});
let draggie = new Draggabilly(elem);
//draggie.on("staticClick", btn_onChange);
$("#btn-auto-owo").onclick = btn_onChange;
}

$.ready(function(){

if(!window.Draggabilly){
let draggabilly = GM_getResourceText('draggabilly');
if (draggabilly) {
eval(draggabilly);
}
}
if(!window.Swal){
let sweetalert2 = GM_getResourceText('sweetalert2');
if (sweetalert2) {
eval(sweetalert2);
window.Swal = this.Sweetalert2;
}
}

$.addStyle('https://cdn.bootcdn.net/ajax/libs/font-awesome/4.0.0/css/font-
awesome.min.css');
// display: none;
// line-height: 70px;
$.addStyle(`#auto-owo-container {
z-index: 99999;
position: fixed;
border-radius: 5%;
top: 25%;
left: 85%;
width: 110px;
height: 115px;
border: #fff solid 1.5px;
box-shadow: 0 3px 10px rgb(212 26 104);
text-align: center;
background: rgb(212 26 104);
color: white;
cursor: pointer;
}

.auto-owo-title {
margin: 8px auto;
font-size: 19px;
display: inline-block;
vertical-align: middle;
}

#btn-auto-owo {
position: relative;
margin: auto;
width: 65px;
height: 65px;
border-radius: 50%;
border: #fff solid 1.5px;
box-shadow: 0 3px 10px #d8d225a8;
text-align: center;
background: #d8d225a8;
color: white;
cursor: pointer;
font-size: 1.3em;
display: flex;
justify-content: center;
align-items: center;
}

#btn-auto-owo:hover {
background-image: linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.1));
}
`);
setupButtonDl();
});

You might also like