Instagram Downloader

Lawrence Sim
2020-08-27T19:59:16Z

Quick 'n dirty little userscript for accessing pictures and videos off of Instagram. Everything is accessed via right-clicking image or video. Note: for videos requires viewing the actual post (not just in the feed).

Quick 'n dirty little userscript for accessing pictures and videos off of Instagram.

Instructions: Right-click on the image or video to see a context menu for opening the media in isolation in a new tab. Minor caveat for videos, see below. (As everything comes from the right-click context menu, ensure nothing on your browser is blocking overriding of the rick-click functionality.)

Downloading videos: You can only get the link to videos if directly viewing the post (if on feed, click the three-dots menu on upper-right of post and then 'Go to post'). On the feed, it will only link to the preview image for the video.

Why? Instagram obfuscates videos pretty hard by using an ephemeral BLOB URL that it immediately revokes, making it pretty difficult to access. To get around this, script sends a request to the post's JSON info to pull the media URL, for which it requires the post ID. Unfortunately, post ID isn't easily obtainable in the feed view without injecting code into ReactJS, which just doesn't seen feasible at the moment, so it grabs the post ID from the URL, which is only updated with post ID when viewing the post directly.

https://lawrenzo.com/p/instagram-downloader

Change log

v1.3.2 : May 15, 2023

Sorry y'all. Fixed bit of bug when viewing post.

v1.3.1 : May 14, 2023

Updated to keep in track with shuffles in HTML structure.

Fallback image detection via styles.

Looks for proper frame to apply context menu listener.

Logic to prevent catching profile pics and other non-main images.

v1.2.1 : Jun 28, 2022

Instagram JSON requests now requires empty __d parameter to work.

v1.2.0 : Mar 9, 2022

Remove @grant none to keep in sandbox env.

v1.1.2 : Mar 8, 2022

Minor fix to fetch error catching.

v1.1.1 : Jan 24, 2022

Cleaned up minor bug in reading feed images.

v1.1.0 : Jan 21, 2022

Instagram completely changed the JSON format, which butchered how everyone was pulling post information to get to the original media. Had to redo that section. Should be working now.

v1.0.3 : Jan 11, 2022

Was capturing profile pictures in post comments. Cut that out.

v1.0.2 : Dec 14, 2021

Fix minor bug with query selector in single image posts.

v1.0.1 : Dec 12, 2021

Reorganize script a bit.

Use Fetch API for JSON request.

Fix bugs related to calling stuff on null objects.

v0.5.0 : Dec 10, 2021

Videos linked via call to JSON post information. As it requires post ID (not easily obtained in feed), must be viewing specific post.

v0.4.0 : Dec 8, 2021

Fix mixed videos and images in multiple/gallery posts.

Attempting to fix how videos are downloaded, still working..

v0.3.0 : Oct 27, 2021

Adjust MutationObserver to search in mutations only.

v0.2.0 : Aug 28, 2021

Add support for videos.