Skip to content

Instantly share code, notes, and snippets.

@tinacious
Last active July 8, 2018 20:37
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 tinacious/724490e47af93eeb3959720b9e5ef5f5 to your computer and use it in GitHub Desktop.
Save tinacious/724490e47af93eeb3959720b9e5ef5f5 to your computer and use it in GitHub Desktop.
📸 IG Download bookmarklet
/**
* When on Instagram web, after clicking the image, a modal pops up.
* Running this when the modal is open will work to grab the photo,
* which will be the last photo in the DOM.
* If you get to an IG photo page and the modal is not open, this won't work.
* To use as a bookmarklet, copy this code, create a new bookmark, & paste it after:
* javascript:
*/
(function () {
const images = document.querySelectorAll('img');
const imageCount = images.length;
const enlargedImageIndex = imageCount - 1;
const enlargedImage = images[enlargedImageIndex];
const srcs = enlargedImage.getAttribute('srcset');
const imgSrc = srcs.split(',')[2].split('?')[0];
window.open(imgSrc);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment