Skip to content

Instantly share code, notes, and snippets.

@rajiteh
Last active April 21, 2016 01:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajiteh/04ee4426de2bfabc9eff5309caf1374f to your computer and use it in GitHub Desktop.
Save rajiteh/04ee4426de2bfabc9eff5309caf1374f to your computer and use it in GitHub Desktop.
ghetto-est way to dump images from a telegram chat. just paste the damn thing in your console. works with web.telegram.org
var withJquery = function(callback, version) {
if (typeof version == "undefined") { version = "2.1.1"; }
var script = document.createElement("script");
script.src = "https://code.jquery.com/jquery-" + version + ".min.js";
script.type = "text/javascript";
document.getElementsByTagName("head")[0].appendChild(script);
var interval = setInterval(function() {
if (typeof jQuery === "function") {
window.$ = jQuery;
clearInterval(interval);
callback(jQuery);
}
}, 500);
}
var handBrake = false; var count = 0; var currentImg = 1;
function downEmAll() {
$('[ng-click="nav.prev($event)"]').click();
$('[ng-click="download()"]')[0].click();
currentImg = $("my-i18n-param[name='pos']").text();
count = count + 1; console.log("Downloaded: " + count);
if (!handBrake && currentImg > till && currentImg > 1) {
setTimeout(downEmAll, 500);
}
}
withJquery(function($) {
$('[ng-click="download()"]').one( "click", function() { downEmAll(); });
var count = $("my-i18n-param[name='pos']").text();
console.log("At " + count + " image. Will download " + (count - till) + " images.");
console.log("Click the download button to begin :)")
});
// 1. Open an image in the full screen photo viewer mode. (Media -> Photos -> Click last pic)
// 2. Click on the download button on the open photo to trigger the process.
// Script goes back pic by pic and downloads each one.
// Config values:
// --> If you need to stop in the middle just enter `handBrake = true` in the console.
// --> Set the till value to something smaller than the total number of pics.
// -----> ie: `var till = 200` will make it download all pics from last one to 200.
var till = 170;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment