Instagram Stories Download Tool
// This function takes the Instagram story URL as input and returns the story ID
function getStoryID(url) {
const regex = /instagram.com\/stories\/.*?\/(.*?)\//;
return url.match(regex)[1];
}
// This function takes the story ID and downloads the story content in a specified format
function downloadStory(storyID, format) {
const url = `https://www.instagram.com/stories/${storyID}/?__a=1`;
// Make an AJAX request to get the story data
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const response = JSON.parse(xhr.responseText);
const storyURL = response.data.user.reel.latest_reel_media;
const downloadURL = `https://www.instagram.com/stories/download/${storyURL}/${format}`;
// Create a link element and click it to start the download
const link = document.createElement('a');
link.href = downloadURL;
link.download = `${storyID}.${format}`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
};
xhr.open('GET', url, true);
xhr.send();
}
// Example usage
const storyURL = 'https://www.instagram.com/stories/username/storyID/';
const storyID = getStoryID(storyURL);
downloadStory(storyID, 'mp4');