Skip to content

Instantly share code, notes, and snippets.

@zoten
Forked from nappa85/bitethebot.user.js
Last active August 8, 2018 12:52
Show Gist options
  • Save zoten/a2c71d6629560f5ead965442804bc161 to your computer and use it in GitHub Desktop.
Save zoten/a2c71d6629560f5ead965442804bc161 to your computer and use it in GitHub Desktop.
BiteTheBot hack
// ==UserScript==
// @include https://web.telegram.org/*
// ==/UserScript==
var url = "https://web.telegram.org/#/im?p=@bitethebot";
const action_timeout = 6000;
const min_timeout = 60000;
const max_timeout = 300000;
const start_timeout = 5000;
const max_timeout_delta = max_timeout - min_timeout;
var hack0 = function() {
if(window.location.href == url) {
//document.getElementsByClassName('composer_rich_textarea')[0].innerHTML = ":rocket: Extra";
//unsafeWindow.$('.im_submit').trigger('mousedown');
unsafeWindow.$('button:contains(Extra)').trigger('click');
window.setTimeout(hack1, action_timeout);
}
else {
window.setTimeout(hack0, action_timeout);
}
};
var hack1 = function() {
if(window.location.href == url) {
//document.getElementsByClassName('composer_rich_textarea')[0].innerHTML = ":beer: Beer";
//unsafeWindow.$('.im_submit').trigger('mousedown');
unsafeWindow.$('button:contains(Beer)').trigger('click');
window.setTimeout(hack2, action_timeout);
}
else {
window.setTimeout(hack1, action_timeout);
}
};
var hack2 = function() {
if(window.location.href == url) {
unsafeWindow.$('button:contains(Half Pint)').trigger('click');
window.setTimeout(hack3, action_timeout);
}
else {
window.setTimeout(hack2, action_timeout);
}
};
var hack3 = function() {
if(window.location.href == url) {
//document.getElementsByClassName('composer_rich_textarea')[0].innerHTML = ":arrow_backward: Back";
//unsafeWindow.$('.im_submit').trigger('mousedown');
unsafeWindow.$('button:contains(Back)').trigger('click');
//random between 1 ad 5 minutes
window.setTimeout(hack0, Math.round(min_timeout + Math.random() * max_timeout_delta));
}
else {
window.setTimeout(hack3, action_timeout);
}
};
window.setTimeout(hack0, start_timeout);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment