Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Download all visible telegram stickers images
// 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);
}
@ehsan123456789
Copy link

ehsan123456789 commented Apr 24, 2017

it doesn't work for me
i just copy whole codes
in telegram web i went to console
then send one of the sticker to my self and then click on it to open
and i paste the code and enter

but i see " undefined " down there

please help me

@broncotc
Copy link

broncotc commented Jun 14, 2017

@ehsan123456789 you need to execute the function after define them.

@satouriko
Copy link

satouriko commented Nov 20, 2017

To friends who would like to download stickers,
https://telegram.me/stickerset2packbot
this bot can resolve high resolution images XD

@EXL
Copy link

EXL commented Feb 17, 2018

@rikakomoe, thank you!

@GertSchepens
Copy link

GertSchepens commented Mar 26, 2018

Great work, thanks ^^

@telegramuser
Copy link

telegramuser commented May 10, 2018

Great bot! Thanks a lot OP! I am looking for this for a while now to download some telegram stickers packs :)

@ishanSrt
Copy link

ishanSrt commented May 29, 2018

@rikakomoe that bot works great!! is there something by which i can download entire packs? whos project is that bot?

@nguyenlehai
Copy link

nguyenlehai commented Aug 13, 2018

very thanks 👍

@phoenixlzx
Copy link

phoenixlzx commented Oct 1, 2018

@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.

@Shesh93
Copy link

Shesh93 commented Nov 13, 2018

It works for me

@jarvis3439
Copy link

jarvis3439 commented Jan 28, 2019

this bot is very good

@lubien
Copy link
Author

lubien commented Jun 4, 2019

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment