Skip to content

Instantly share code, notes, and snippets.

@huksley
Created August 9, 2025 13:35
Show Gist options
  • Save huksley/cde2623f3c77ca7aa57ad92dd0882d78 to your computer and use it in GitHub Desktop.
Save huksley/cde2623f3c77ca7aa57ad92dd0882d78 to your computer and use it in GitHub Desktop.
Get all reactions as portraits from Telegram
function getBase64Image(img) {
var canvas = document.createElement("canvas");
canvas.width = img.naturalWidth;
canvas.height = img.naturalHeight;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
var dataURL = canvas.toDataURL("image/png");
return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
}
els = Array.from(
document.querySelector(
"html.notranslate.theme-dark body#root.ThfRMqwq.is-pointer-env.is-macos div#portals div div.Modal.ReactorListModal.narrow.opacity-transition.fast.shown.open div.modal-container div.modal-dialog div.modal-content.custom-scroll div.reactor-list-wrapper div.reactor-list.custom-scroll"
).childNodes
).filter(s => s.querySelector);
html2 =
"<div style='display: inline-flex; flex-wrap: wrap; gap: 8px'>" +
els
.sort(
(a, b) =>
a
.querySelector(".fullName")
.innerText?.localeCompare(b.querySelector(".fullName").innerText) || 0
)
.map(
e =>
"<a href='https://web.telegram.org/a/#" +
e.querySelector("[data-peer-id]").getAttribute("data-peer-id") +
"' target='_blank' style='display: inline-flex; flex-direction: column; gap: 4px; border: 1px solid black; padding: 4px; border-radius: 4px;'><img src='data:image/jpeg;base64," +
getBase64Image(e.querySelector("img")) +
"'/><span>" +
e.querySelector(".fullName").innerText +
"</span></a>"
)
.join("\n") +
"</div>";
var ww = window.open("");
ww.document.write(html2);
@huksley
Copy link
Author

huksley commented Aug 9, 2025

Open post => Reactions as popup and execute in the console this script. It will open a new window with portraits, links and names.

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