-
-
Save lubien/dd31722dbb30d2ca2b7a55d21e69cfed to your computer and use it in GitHub Desktop.
// How to download telegram sticker images | |
/* | |
1. Go to Telegram Web; | |
2. Open console (F12); | |
3. Paste the code below in the console and press Enter; | |
4. Open your stickers menu and make sure you see the sticker pack you want to download (so Telegram will load it). | |
5. At the console paste and run "downloadStickers()" any time you want to download a pack. | |
6. [Convert .webm to another format](http://www.freewaregenius.com/convert-webp-image-format-jpg-png-format/); | |
7. Happy hacking. | |
If you close the tab or refresh it, you should do step 3 again. | |
*/ | |
// Main function | |
function downloadStickers() { | |
// Find all sticker sets | |
const sets = querySelectorAll('.composer_stickerset_wrap') | |
// We need it's title to prompt users | |
.map(set => { | |
const $title = querySelector('.composer_stickerset_title', set); | |
return { | |
key: $title.attributes['data-stickerset'].value, | |
title: $title.innerText, | |
node: set, | |
}; | |
}) | |
// Those without key aren't packs. "Frequently used" for example. | |
.filter(({key}) => key !== ''); | |
// Ask which pack the user want to download | |
const selectedSet = prompt( | |
// Join them into a list of keys-titles | |
sets | |
.map(({title}, i) => `[${i}]: ${title}`) | |
.join('\n') | |
); | |
// Find all images | |
querySelectorAll('img', sets[+selectedSet].node) | |
// Only care about it's URL | |
.map(i => i.attributes.src.value) | |
// Filter those with `sticker` in the URL | |
// .filter(i => /sticker/.test(i))) | |
// Download all | |
.forEach(download); | |
} | |
// DOM query helpers | |
// These two do 90% of what you need JQuery for | |
const querySelector = (query, el = window.document) => | |
el.querySelector(query); | |
const querySelectorAll = (query, el = window.document) => | |
Array.from(el.querySelectorAll(query)); | |
// Trigger a download | |
function download(image) { | |
// Create a dummy element | |
var a = document.createElement('a'); | |
a.href = image; | |
// `download` attribute means that clicks trigger download | |
a.download = ""; | |
document.body.appendChild(a); | |
a.click(); | |
document.body.removeChild(a); | |
} |
this bot is very good
Surprised to see there where people over here as GitHub doesn't notify at all about comments on gists.
Bot is the way to go :)
To friends who would like to download stickers, https://telegram.me/stickerset2packbot this bot can resolve high resolution images XD
The bot does not work, I create another instance https://t.me/AnotherStickerDownloadBot
@rikakomoe @ishanSrt It's mine and it's open source. https://github.com/phoenixlzx/telegram-stickerimage-bot https://t.me/stickerset2packbot
I finally have some time to update the code. Now you may try with send this bot a sticker link (something like https://t.me/addstickers/Amashiro_Natsuki ) after /newpack Or send individual sticker to get a PNG without /newpack
Both are new added features.
hi, thanks for making the bot! Anyways, is there any chance you can bump the queue limit? I'm trying to download a sticker set with 120+ stickers and it wont let me split the set without manually inputting each sticker. Thanks in advance!
@rikakomoe @ishanSrt It's mine and it's open source. https://github.com/phoenixlzx/telegram-stickerimage-bot https://t.me/stickerset2packbot
I finally have some time to update the code. Now you may try with send this bot a sticker link (something like https://t.me/addstickers/Amashiro_Natsuki ) after /newpack Or send individual sticker to get a PNG without /newpack
Both are new added features.hi, thanks for making the bot! Anyways, is there any chance you can bump the queue limit? I'm trying to download a sticker set with 120+ stickers and it wont let me split the set without manually inputting each sticker. Thanks in advance!
The limit was introduced when I found Telegram limits the file size to 50MB for bots. With that being said, since it will automatically split file to work around this I have lifted the value to 200.
It works for me