Skip to content

Instantly share code, notes, and snippets.

@co3moz
Last active May 21, 2018 15:09
Show Gist options
  • Save co3moz/14c61d6a01f536706a3995e4b045d58f to your computer and use it in GitHub Desktop.
Save co3moz/14c61d6a01f536706a3995e4b045d58f to your computer and use it in GitHub Desktop.
thecrims-bot
var getRobberies = function (done) {
console.log('%c Soygun seçiliyor.', 'background: black; color: white')
$.ajax({
type: "GET",
url: 'https://www.thecrims.com/api/v1/robberies',
success: function (res) {
done(res.single_robberies
.filter(robbery => robbery.successprobability == 100)
.sort((a, b) => b.difficulty - a.difficulty)
.find((x, index) => index == 0))
}
});
}
var getNightClubs = function (done) {
console.log('%c Klüplere bakılıyor.', 'background: black; color: white')
$.ajax({
type: "GET",
url: 'https://www.thecrims.com/api/v1/nightclubs',
success: function (res) {
done(res.favorites.length > 0 ? res.favorites : res.nightclubs)
}
});
}
var joinClub = function (club, done) {
console.log('%c ' + club.name + ' klübüne girdi.', 'background: black; color: white')
$.ajax({
type: "POST",
url: 'https://www.thecrims.com/api/v1/nightclub',
data: { id: club.id, mm: [], mc: [], kp: [] },
success: function (res) {
done(res)
},
error: function () {
console.log('%c Bilet bitti :(', 'background: red; color: white')
}
});
}
var drink = function (drug, done, currentStamina) {
var amount = currentStamina ? parseInt((105 - currentStamina) / drug.stamina) : 1;
if (amount > 99) {
amount = 99
}
console.log('%c ' + amount + ' adet ' + drug.name + ' içiliyor', 'background: yellow; color: black')
$.ajax({
type: "POST",
url: 'https://www.thecrims.com/api/v1/nightclub/drug',
data: { id: drug.id, quantity: amount, mm: [], mc: [], kp: [] },
success: function (res) {
console.log('%c Güç: ' + res.user.stamina, 'background: green; color: white')
if (res.user.stamina < 100) {
drink(drug, done, res.user.stamina)
} else {
if (res.user.addiction > 5) {
heal(done);
} else {
done()
}
}
},
error: function () {
power(done)
}
});
}
var heal = function (done) {
console.log('%c Tedaviye gidiliyor.', 'background: black; color: white')
$.ajax({
type: "POST",
url: 'https://www.thecrims.com/api/v1/hospital/healing',
data: { id: 10, quantity: 1, mm: [], mc: [], kp: [] },
success: function (res) {
console.log('%c Bağımlılık: ' + res.user.addiction, 'background: green; color: white')
if (res.user.addiction > 0) {
heal(done)
} else {
done()
}
}
});
}
var power = function (done) {
getNightClubs(function (clubs) {
var clubIndex = Math.floor(Math.random() * Math.floor(clubs.length));
joinClub(clubs[clubIndex], function (res) {
var drugIndex = Math.floor(Math.random() * Math.floor(res.nightclub.products.drugs.length));
drink(res.nightclub.products.drugs[drugIndex], done)
})
})
}
function click(info, n) { n = document.querySelector(n); if (n && n.style.display != 'none') { n.style.display = 'none'; n.click(); console.log(info); } }
function innerTextGet(n) { n = document.querySelector(n); if (n) return n.innerText; return null; }
function getRate(n) { n = innerTextGet(n); if (n) { n = /(\d+)\/(\d+)/.exec(n); if (n) { console.log(n[0]); return n[2] == n[1]; } } return false; }
function controlPower() {
return new Promise(resolve => {
if (+innerTextGet('#user-profile-stamina').replace(/[^0-9]/g, '') < 25) {
document.querySelector('#user-profile-stamina').innerText = "100%";
power(resolve);
} else resolve();
});
}
function delay(n) { return new Promise(resolve => setTimeout(resolve, n)) }
function tikla(olustur) {
var lock = false;
setInterval(async x => {
if (lock) return;
lock = true;
if (olustur) {
if (getRate('#content_middle > div > div:nth-child(3) > div:nth-child(6) > div > div:nth-child(4)'))
click('yap', '#content_middle > div > div:nth-child(3) > div:nth-child(6) > div > div.text-center > button.btn.btn-inverse.btn-small')
await delay(2000);
await controlPower();
click('oluştur', '#content_middle > div > div:nth-child(3) > div:nth-child(5) > table > tr > td:nth-child(1) > button');
} else {
await controlPower();
click('kabul et', '#content_middle > div > div:nth-child(3) > div:nth-child(6) > div > div.text-center > button.btn.btn-success.btn-small')
}
await delay(1500);
lock = false;
}, 250);
}
var request = (type, url, data) => new Promise((success, error) => $.ajax({ type, data, url: 'https://www.thecrims.com/api/v1/' + url, success, error }));
var getRobberies = (setting) => request('GET', 'robberies', null).then(data => {
if (setting.pick) return data.single_robberies.filter(robbery => robbery.long_name.indexOf(setting.pick) != -1)[0];
return data.single_robberies.filter(robbery => robbery.successprobability == 100).sort((a, b) => b.difficulty - a.difficulty)[0];
});
var getNightClubs = () => request('GET', 'nightclubs', null).then(x => x.favorites.length > 0 ? x.favorites : nightclubs)
var joinClub = (club) => request('POST', 'nightclub', { id: club.id, mm: [], mc: [], kp: [] })
var drink = (drug, stamina) => request('POST', 'nightclub/drug', { id: drug.id, quantity: drugAmount(drug, stamina), mm: [], mc: [], kp: [] }).then(x => x.user.stamina < 100 ? drink(drug, x.user.stamina) : (x.user.addiction > 5 ? heal() : x))
var heal = () => request('POST', 'hospital/healing', { id: 10, quantity: 1, mm: [], mc: [], kp: [] }).then(x => x.user.addiction > 0 ? heal() : x);
var power = () => getNightClubs().then(x=> joinClub(x[Math.random() * x.length >>> 0])).then(x=> drink(x.nightclub.products.drugs[Math.random() * x.nightclub.products.drugs.length >>> 0]))
var rob = (robbery) => request('POST', 'rob', {id: robbery.id, mm:[], mc:[], kp:[]}).then(x=> x.user.stamina < robbery.energy ? x : rob(robbery));
var bot = (setting = {}) => getRobberies(setting).then(x=> rob(x)).then(x=> power()).then(x=> bot(setting));
Array.from(document.querySelectorAll('#content_middle > div > div:nth-child(3) > table.table.table-condensed.table-top-spacing > tbody > tr')).map(x=> +x.querySelector('td:nth-child(2)').innerText.replace(/\$|,|\./g, '') * +x.querySelector('td:nth-child(3)').innerText.replace(/\$|,|\./g, '')).reduce((total, x) => total+x, 0) / 20000
Array.from(document.querySelectorAll('#content_middle > div > div:nth-child(3) > table.table.table-condensed.table-top-spacing > tbody > tr')).map(x=>({name: x.querySelector('td:nth-child(1)').innerText, value: x.querySelector('td:nth-child(3)').innerText.replace(/\$|,/g, '')/x.querySelector('td:nth-child(2)').innerText.replace(/\$|,/g, '') })).sort((a,b)=> a.value - b.value)[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment