Skip to content

Instantly share code, notes, and snippets.

@snidima
Last active April 11, 2024 18:33
Show Gist options
  • Select an option

  • Save snidima/42f7fa1080a52db56b56dbaf09c04c8d to your computer and use it in GitHub Desktop.

Select an option

Save snidima/42f7fa1080a52db56b56dbaf09c04c8d to your computer and use it in GitHub Desktop.
let limit = 4 // сколько раз кликнуть
let timep = 20 // пауза в секундах
let notifytime = 300000 // пауза в тг
let count = 0
let paused = false
class TelegramBotSetup {
constructor(token) {
this.token = token;
this.requestUrl = 'https://api.telegram.org/bot';
}
api(type, method, body) {
return new Promise((resolve, reject) => {
fetch(this.requestUrl + this.token + type, {
method: method,
body: body
}).then(res => {
resolve(res.json())
}).catch(err => {
reject(err)
})
})
}
}
class Bot extends TelegramBotSetup {
constructor(botToken, defaultChatID) {
super(botToken);
this.dcid = defaultChatID;
}
static start() {
console.log("Send telegram message with JS\nDeveloper: https://manuchehr.me\nDocs: https://github.com/manuchekhr32/send-telegram-message-with-js");
}
async getUpdates() {
try {
const result = await this.api('/getUpdates', 'GET')
return await result
} catch(e) {
return await e
}
}
async getMe() {
try {
const result = await this.api('/getMe', 'GET')
return await result
} catch(e) {
return await e
}
}
async sendMessage(text, chatID, parseMode, disableNotification) {
try {
const result = await this.api(`/sendMessage?text=${text}&chat_id=${chatID ? chatID : this.dcid}&parse_mode=${parseMode ? parseMode : 'html'}&disable_notification=${disableNotification ? disableNotification : false}`, 'GET')
return await result
} catch(e) {
return await e
}
}
async sendPhoto(img, caption, chatID, parseMode, disableNotification) {
try {
if (img.startsWith('#')) {
const file = document.getElementById(img.replace('#', ''));
const formData = new FormData();
formData.append("photo", file.files[0])
const result = await this.api(`/sendPhoto?caption=${caption ? caption : ''}&chat_id=${chatID ? chatID : this.dcid}&parse_mode=${parseMode ? parseMode : 'html'}&disable_notification=${disableNotification ? disableNotification : false}`,
'POST', formData)
return await result
}
else if (typeof img === 'string') {
const result = await this.api(`/sendPhoto?photo=${img}&caption=${caption ? caption : ''}&chat_id=${chatID ? chatID : this.dcid}&parse_mode=${parseMode ? parseMode : 'html'}&disable_notification=${disableNotification ? disableNotification : false}`, 'GET')
return await result
}
} catch(e) {
return await e
}
}
async sendAudio(audio, caption, chatID, parseMode, disableNotification) {
try {
if (audio.startsWith('#')) {
const file = document.getElementById(audio.replace('#', ''));
const formData = new FormData();
formData.append("audio", file.files[0])
const result = await this.api(`/sendAudio?caption=${caption ? caption : ''}&chat_id=${chatID ? chatID : this.dcid}&parse_mode=${parseMode ? parseMode : 'html'}&disable_notification=${disableNotification ? disableNotification : false}`,
'POST', formData)
return await result
}
else if (typeof audio === 'string') {
const result = await this.api(`/sendAudio?audio=${audio}&caption=${caption ? caption : ''}&chat_id=${chatID ? chatID : this.dcid}&parse_mode=${parseMode ? parseMode : 'html'}&disable_notification=${disableNotification ? disableNotification : false}`, 'GET')
return await result
}
} catch(e) {
return await e
}
}
async sendVoice(voice, caption, chatID, parseMode, disableNotification) {
try {
if (voice.startsWith('#')) {
const file = document.getElementById(voice.replace('#', ''));
const formData = new FormData();
formData.append("voice", file.files[0])
const result = await this.api(`/sendVoice?caption=${caption ? caption : ''}&chat_id=${chatID ? chatID : this.dcid}&parse_mode=${parseMode ? parseMode : 'html'}&disable_notification=${disableNotification ? disableNotification : false}`,
'POST', formData)
return await result
}
else if (typeof voice === 'string') {
const result = await this.api(`/sendVoice?voice=${voice}&caption=${caption ? caption : ''}&chat_id=${chatID ? chatID : this.dcid}&parse_mode=${parseMode ? parseMode : 'html'}&disable_notification=${disableNotification ? disableNotification : false}`, 'GET')
return await result
}
} catch(e) {
return await e
}
}
async sendVideo(video, caption, chatID, parseMode, disableNotification) {
try {
if (video.startsWith('#')) {
const file = document.getElementById(video.replace('#', ''));
const formData = new FormData();
formData.append("video", file.files[0])
const result = await this.api(`/sendVideo?caption=${caption ? caption : ''}&chat_id=${chatID ? chatID : this.dcid}&parse_mode=${parseMode ? parseMode : 'html'}&disable_notification=${disableNotification ? disableNotification : false}`,
'POST', formData)
return await result
}
else if (typeof video === 'string') {
const result = await this.api(`/sendVideo?video=${video}&caption=${caption ? caption : ''}&chat_id=${chatID ? chatID : this.dcid}&parse_mode=${parseMode ? parseMode : 'html'}&disable_notification=${disableNotification ? disableNotification : false}`, 'GET')
return await result
}
} catch(e) {
return await e
}
}
async sendFile(doc, caption, chatID, parseMode, disableNotification) {
try {
if (doc.startsWith('#')) {
const file = document.getElementById(doc.replace('#', ''));
const formData = new FormData();
formData.append("document", file.files[0])
const result = await this.api(`/sendDocument?caption=${caption ? caption : ''}&chat_id=${chatID ? chatID : this.dcid}&parse_mode=${parseMode ? parseMode : 'html'}&disable_notification=${disableNotification ? disableNotification : false}`,
'POST', formData)
return await result
}
else if (typeof doc === 'string') {
const result = await this.api(`/sendDocument?document=${doc}&caption=${caption ? caption : ''}&chat_id=${chatID ? chatID : this.dcid}&parse_mode=${parseMode ? parseMode : 'html'}&disable_notification=${disableNotification ? disableNotification : false}`, 'GET')
return await result
}
} catch(e) {
return await e
}
}
async sendContact(phoneNumber, firstName, lastName, chatID, parseMode, disableNotification) {
try {
const result = await this.api(`/sendContact?phone_number=${phoneNumber}&first_name=${firstName}&last_name=${lastName ? lastName : ''}&chat_id=${chatID ? chatID : this.dcid}&parse_mode=${parseMode ? parseMode : 'html'}&disable_notification=${disableNotification ? disableNotification : false}`, 'GET')
return await result
} catch(e) {
return await e
}
}
async sendLocation(latitude, longitude, chatID, parseMode, disableNotification) {
try {
const result = await this.api(`/sendLocation?latitude=${latitude}&longitude=${longitude}&chat_id=${chatID ? chatID : this.dcid}&parse_mode=${parseMode ? parseMode : 'html'}&disable_notification=${disableNotification ? disableNotification : false}`, 'GET')
return await result
} catch(e) {
return await e
}
}
async sendPoll(question, options, config, chatID, disableNotification) {
try {
let url = `/sendPoll?question=${question}&options=${JSON.stringify(options)}&chat_id=${chatID ? chatID : this.dcid}&disable_notification=${disableNotification ? disableNotification : false}`
for (let i in config) {
url += `&${i}=${config[i]}`
}
const result = await this.api(url, "GET")
return await result
} catch(e) {
return await e
}
}
}
Bot.start()
/***********************************************************************/
/***********************************************************************/
let t1 = 1 * 1000
window.alert = console.log
const canvases = document.querySelectorAll("canvas");
canvases.forEach((canvas) => {
canvas.style.display = "none"
});
document.querySelector('[class^="RewardsNotificationsStyled"]').style.display = "none"
document.querySelector('[class^="TargetProgressContent-sc"]').style.display = "none"
//document.querySelector('body').style.display = "none"
let target = document.querySelector('[class^="CanvasContainerBottom"]');
document.querySelector('[class^="CanvasContainerBottom"] > button:nth-of-type(2)').click()
let observer = new MutationObserver(function(mutations) {
let target2 = document.querySelector('[class^="CanvasContainerBottom"] > button:nth-of-type(2)')
if( count == limit ) {
paused = true
setTimeout( () => {
console.log("30s")
count = 0
paused = false
let qweeeee = document.querySelector('[class^="CanvasContainerBottom"] > button:nth-of-type(2)')
qweeeee.click()
}, timep * 1000)
}
if( !target2.disabled && !paused ) {
setTimeout(()=>{
target2.click()
count++
console.log(count)
},t1)
}
});
observer.observe(target, {
childList: true,
subtree: true,
});
function loadScript(src, callback)
{
var s,
r,
t;
r = false;
s = document.createElement('script');
s.type = 'text/javascript';
s.src = src;
s.onload = s.onreadystatechange = function() {
//console.log( this.readyState ); //uncomment this line to see which ready states are called.
if ( !r && (!this.readyState || this.readyState == 'complete') )
{
r = true;
callback();
}
};
t = document.getElementsByTagName('script')[0];
t.parentNode.insertBefore(s, t);
}
const bot = new Bot("7182715106:AAHCrfL-IBRRyq0sWqu7f9dVo8hjOzuTYZ4", "-4136293418")
function notify(){
let score = document.querySelector('[class^="AnimatedNumberStyled"]').textContent
let name = Telegram.WebApp.initDataUnsafe.user.username
let user_id = Telegram.WebApp.initDataUnsafe.user.id
bot.sendMessage(`${name}: ${score}`, null, null, true)
}
notify()
setInterval(notify, notifytime)
/***********************************************************************/
function httpGet(theUrl, token = null)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "PUT", theUrl, false );
if( token ) {
xmlHttp.setRequestHeader("Authorization", "Bearer " + token)
}
xmlHttp.send( null );
return xmlHttp.responseText;
}
let reqToken = httpGet("https://thepixels.fireheadz.games/api/auth/telegram/" + btoa( Telegram.WebApp.initData ) + "?_p=weba" )
let token = JSON.parse(reqToken).accessToken
function applyBoost(){
httpGet("https://thepixels.fireheadz.games/api/shop/buy-booster/0", token) // DOUBLE BOOSTER
// httpGet("https://thepixels.fireheadz.games/api/shop/buy-booster/7", token) // PIXEL LOCATOR
// httpGet("https://thepixels.fireheadz.games/api/shop/buy-booster/1", token) // TRIPLE POWER
// httpGet("https://thepixels.fireheadz.games/api/shop/buy-booster/2", token) // QUADRO
// httpGet("https://thepixels.fireheadz.games/api/shop/buy-booster/3", token) // PENTA PUSHER
// httpGet("https://thepixels.fireheadz.games/api/shop/buy-booster/4", token) // NAGIBATOR
// httpGet("https://thepixels.fireheadz.games/api/shop/buy-booster/6", token) // RANDIMIZER
}
applyBoost()
setInterval(applyBoost, 5 * 1000 * 60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment