Skip to content

Instantly share code, notes, and snippets.

@PofMagicfingers
Created January 31, 2022 09:42
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 PofMagicfingers/767c1e9b3a5194c744fd39135e0921d1 to your computer and use it in GitHub Desktop.
Save PofMagicfingers/767c1e9b3a5194c744fd39135e0921d1 to your computer and use it in GitHub Desktop.
Download all stories from Snapchat data archive ( memories_history.html ) by converting them to a bash script using curl
// Open memories_history.html, and open the developer console, paste this code :
function download(filename, text) {
var element = document.createElement("a");
element.setAttribute(
"href",
"data:text/plain;charset=utf-8," + encodeURIComponent(text)
);
element.setAttribute("download", filename);
element.style.display = "none";
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
var a = [...document.querySelectorAll("table tr")].slice(1);
var cc = a.map(
(a, i, all) =>
`echo ${i}/${all.length - 1} \n curl -0 -o ${new Date(
a.querySelector("td:nth-of-type(1)").innerText // Date
)
.toISOString()
.replace("T", "_")
.replace(/:/g, "-")
.replace(".000Z", "")}${
a.querySelector("td:nth-of-type(2)").innerText == "Image" // Type
? ".jpg"
: ".mp4"
} $(${(() => {
t = a.querySelector("td a").href;
b = t.replace("%27);", "").replace("javascript:downloadMemories('", "");
c = b.split("?");
return `curl -d "${c[1]}" -X POST ${c[0]}`; // Subcall to curl to get real data url
})()})`
);
download(
"dls_snap.sh",
`#!/bin/bash
set +e
` + cc.join("\n\n")
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment