Skip to content

Instantly share code, notes, and snippets.

@Rican7
Last active November 7, 2019 00:00
Show Gist options
  • Save Rican7/e516103c31d3e7530ad2d688d137b608 to your computer and use it in GitHub Desktop.
Save Rican7/e516103c31d3e7530ad2d688d137b608 to your computer and use it in GitHub Desktop.
Open all media of an Instagram post in new tabs (windows). (NOTE: Only works on direct post page links, not "lightboxed" posts from profile pages)
(function (scope) {
/* NOTE: Comments are all in "block" form for easier bookmark one-lining */
/* Public pages will hold their entry data here */
let entries = scope._sharedData.entry_data.PostPage;
/* If the data doesn't exist there... */
if (entries[0].graphql === undefined) {
/* Logged in pages will have the data stored in a different location */
entries = Object.values(scope.__additionalData).map(x => x.data);
}
for (let entry of entries) {
let entryMedia = entry.graphql.shortcode_media;
if (entryMedia.edge_sidecar_to_children) {
for (let edge of entryMedia.edge_sidecar_to_children.edges) {
window.open(edge.node.display_url, "_blank");
}
} else {
window.open(entryMedia.display_url, "_blank");
}
}
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment