Skip to content

Instantly share code, notes, and snippets.

@rileyjshaw
Created March 19, 2018 07:01
Show Gist options
  • Save rileyjshaw/6472d10d9898dd075c89a62c16ddab37 to your computer and use it in GitHub Desktop.
Save rileyjshaw/6472d10d9898dd075c89a62c16ddab37 to your computer and use it in GitHub Desktop.
Grab and print all captions from your Instagram feed.
// A bunch of tools exist for downloading Instagram photos
// (eg. chrome.google.com/webstore/detail/olkpikmlhoaojbbmmpejnimiglejmboe)
// but not as many grab your captions. This is quick and dirty, in the spirit of
// https://gist.github.com/rileyjshaw/953b3aba4c48e34b0069152f5fc21e4c.
// In your browser of choice, open up the Web Console and paste in the following.
// You might need to change some `querySelector` calls to match the Instagram web
// client's current markup.
// Fragile! Based on a generated classname. Replace this with whatever selector
// will match the main image container.
var mainContainer = document.querySelector('._havey');
// But also, this is all super fragile. It relies on very specific element and
// sibling placement. It'll probably need some massaging to match the current
// document setup.
!function moar (imgs) {
var perhapsEvenMoarImgs = imgs.concat(Array
.from(mainContainer.querySelectorAll('img'))
.filter(img => imgs.indexOf(img) === -1)
);
// Also super fragile.
if (mainContainer.parentElement.nextSibling) {
var lastImg = perhapsEvenMoarImgs[perhapsEvenMoarImgs.length - 1];
var dY = lastImg.getBoundingClientRect().bottom;
window.scrollTo(0, window.scrollY + dY);
setTimeout(() => moar(perhapsEvenMoarImgs), 500);
} else {
console.log("\"" + perhapsEvenMoarImgs
.map(img => img.alt.replace(/\"/g, "\\\""))
.join("\", \"")
+ "\"");
alert("Finished! Check ur console.");
}
}([]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment