Skip to content

Instantly share code, notes, and snippets.

@nhatminhbui
Last active January 5, 2022 05:04
Show Gist options
  • Save nhatminhbui/f95303448124d47b77fb9f4764b59ad9 to your computer and use it in GitHub Desktop.
Save nhatminhbui/f95303448124d47b77fb9f4764b59ad9 to your computer and use it in GitHub Desktop.
javascript:
var description = 'Instagram Photo & Stories Download';
var copyright = 'Nhat Bui (nhatminhbui.github.io)';
function getImgURL() {
x = window.innerWidth*3/7;
y = window.innerHeight/2;
img = document.elementsFromPoint(x, y);
while (typeof img == 'undefined') {
}
return img[1].src;
}
function getStoryURL() {
function getStoryImgURL() {
img_src = story[3].src;
if (img_src.includes('e35/c0.')) {
return story[3].srcset.split(' ')[0];
} else return story[3].src;
}
function getStoryVideoURL() {
if (typeof story[3].firstChild.src == 'undefined') {
return story[5].firstChild.src;
} else return story[3].firstChild.src;
}
x = window.innerWidth/2;
y = window.innerHeight/2;
story = document.elementsFromPoint(x, y);
while (typeof story == 'undefined') {
}
if (story[3].firstChild === null) {
return getStoryImgURL();
} else {
return getStoryVideoURL();
}
}
url = document.URL;
if (url.includes("stories")) {
window.open(getStoryURL(), '_blank');
} else {
window.open(getImgURL(), '_blank');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment