i’m a little paranoid on using 3rd-party website like downloadgram.com
so i devised this little javascript to use the information already loaded in the instagram page, which also does not require Scriptable at all. all native within Shortcuts without passing anything to other website.
use a Run JavaScript on Webpage
action with the following script with the instagram page as Safari webpage
. the output is a list of links separated by line breaks for downloading use (which i’m certain you can figure out how to do in Shortcuts).
this script can handle instagram posts with:
- single photo
- single video
- multiple items with a mix of photos and videos
have fun.
let instaObj, mediaLink = ''
// read code and init instagram variables
instaObj = JSON.parse(
/[^{]+(.+)/.exec(
/window.__additionalDataLoaded\((.+)\);/i.exec(
document.documentElement.outerHTML
)[1]
)[1]
).graphql.shortcode_media
// extract link to photo/video
if (instaObj.edge_sidecar_to_children) {
// multiple items
mediaLink = instaObj.edge_sidecar_to_children.edges
.map(p => ( p.node.is_video ? p.node.video_url : p.node.display_url ))
.join('\n')
} else if (instaObj.is_video) {
// single video
mediaLink = instaObj.video_url
} else {
// single photo
mediaLink = instaObj.display_url
}
// pass result as output
completion(mediaLink)