Created
March 19, 2018 07:01
-
-
Save rileyjshaw/6472d10d9898dd075c89a62c16ddab37 to your computer and use it in GitHub Desktop.
Grab and print all captions from your Instagram feed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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