For those who want to get started quickly, the instructions are below.
If you use the Network tab in DevTools, you'll naturally find links to mp4s. There are many links, with varying qualities.
But the funny thing is that there are two links for the same video size: one for the video and one for the audio. In other words, there is a video without audio and an audio without a video.
However, a link to a full-length video is already present in the code of the requested page, using the video_versions key.
But I need to get comfortable.
All JSON configs are located in the tag with the data-sjs attribute. However, as is currently fashionable, there is an excessive amount of data with numerous array attachments.
The desired config can be identified using ScheduledServerJS, but this is not a unique marker.
Therefore, in order not to overload the code (and not to scare the uninitiated), a recursive search of video_versions is performed on all data.
Attention! This code will only work if the video post/story/reels page is open. The URL in the address bar must be of the following format:
https://www.instagram.com/p/<id>/\nhttps://www.instagram.com/reels/<id>/\nhttps://www.instagram.com/stories/<username>/<id>/If the URL is correct, you need to reload the page (F5) and then use the method. This is because the address changes using javascript during surfing, without fully reloading the page.
function search(data, needle) {\n\tfor (let key in data) {\n\t\tif (key === needle) {\n\t\t\treturn data[key];\n\t\t}\n\t\tif (data[key] !== null\n\t\t\t&& typeof data[key] === 'object'\n\t\t\t&& (video = search(data[key], needle))) {\n\t\t\treturn video;\n\t\t}\n\t}\n\treturn undefined;\n}\n\ndocument.querySelectorAll('[data-sjs]').forEach(e => {\n\tvar data = JSON.parse(e.innerText);\n\tif (video = search(data, 'video_versions')) {\n\t\tconsole.log(video);\n\t}\n});
I don't know what the developers want to say, but these three links are the same...