Skip to content

Commit

Permalink
v11.0.0 🌞⭐ Project sunny star
Browse files Browse the repository at this point in the history
  • Loading branch information
saschaheim committed Jun 4, 2022
1 parent e4e992e commit 3f09935
Show file tree
Hide file tree
Showing 13 changed files with 714 additions and 545 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# <img style="float: left; vertical-align: bottom; " width="35" src="https://upload.wikimedia.org/wikipedia/commons/4/4c/Typescript_logo_2020.svg"> [instantgram] v10.1.3
![GitHub release](https://img.shields.io/badge/release-v10.1.3-green)
# <img style="float: left; vertical-align: bottom; " width="35" src="https://upload.wikimedia.org/wikipedia/commons/4/4c/Typescript_logo_2020.svg"> [instantgram] v11.0.0 :sun_with_face::star: Project sunny star
![GitHub release](https://img.shields.io/badge/release-v11.0.0-green)

![badge](https://img.shields.io/badge/for-instagram-yellow.svg?style=flat-square)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)
Expand Down Expand Up @@ -39,6 +39,8 @@ With this version we support all modern browsers that have ECMAScript 2015 (es6)
Read [CONTRIBUTING.md](CONTRIBUTING.md) for more information. :heart:

## Changelog
- v11.0.0 - [instangram] Now compatible with new Instagram layout/design. \
Bulk profile page downloader disabled because of instagram changed APIs, searching in future releases for a hot fix.
- v10.1.3 - [instangram] Fix saving videos on some post types.
- v10.1.2 - [instangram] Fix issue #17 can't save most types of videos anymore.
- v10.1.1 - [instangram] Fix profile page downloading doesn't work anymore.
Expand Down
2 changes: 1 addition & 1 deletion dist/main.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lang/de-de/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lang/en-us/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lang/es-ar/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lang/pt-br/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "instantgram",
"version": "10.1.3",
"version": "11.0.0",
"description": "A bookmarklet for download photos in Instagram",
"author": "Matheus Falcão and from 4.0.0 Sascha Heim",
"homepage": "https://thinkbig-company.github.io/instantgram/",
Expand Down
2 changes: 1 addition & 1 deletion src/_langs/partials/button.html

Large diffs are not rendered by default.

99 changes: 58 additions & 41 deletions src/helpers/getBlobVideoUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,95 +2,112 @@ import getDataFromUrl from './getDataFromUrl'

async function getBlobVideoUrl(el: HTMLVideoElement, article: any, pos: number, callback: any) {
/* Will be used only for single video posts */
let isMultiVideo = (pos != null) ? true : false;
let isMultiVideo = (pos != null) ? true : false
if (!isMultiVideo) {
let posterRegex = /poster\=\"([\s\S]*)\" preload/gm;
let posterRegexMatch = posterRegex.exec(el.outerHTML.replace(/(\r\n|\n|\r)/gm, ''));
let videoPosterUrl = null;
let posterRegex = /poster\=\"([\s\S]*)\" preload/gm
let posterRegexMatch = posterRegex.exec(el.outerHTML.replace(/(\r\n|\n|\r)/gm, ''))
let videoPosterUrl = null
if (posterRegexMatch) {
// HACK
let div = document.createElement('textarea');
div.innerHTML = posterRegexMatch[1];
let decoded = div.firstChild.nodeValue;
videoPosterUrl = decoded;
let div = document.createElement('textarea')
div.innerHTML = posterRegexMatch[1]
let decoded = div.firstChild.nodeValue
videoPosterUrl = decoded
}
var videoPosterFilename = videoPosterUrl.split('/').pop().split('#')[0].split('?')[0];
var videoPosterFilename = videoPosterUrl.split('/').pop().split('#')[0].split('?')[0]

if (process.env.DEV) {
console.log(['getBlobVideoUrl(): videoPosterFilename', videoPosterFilename]);
console.log(['getBlobVideoUrl(): videoPosterFilename', videoPosterFilename])
}
}

if (article != null) {
if (process.env.DEV) {
console.log(['getBlobVideoUrl(): isMultiVideo', isMultiVideo])
console.log(['getBlobVideoUrl(): hasArticle', article !== null])
console.log(['getBlobVideoUrl(): article', article])
console.log(['getBlobVideoUrl(): el', el])
}

if (article !== null) {
/* Step 1 */
/* Fetch user id from element */
let userId = null;
let userProfileUrl = '';
let userId = null
let userProfileUrl = ''
if (article !== undefined && article.length > 0) {
userProfileUrl = (article[0].querySelectorAll('header > div > div > div > div > span > a')[0] as HTMLLinkElement).href;
userProfileUrl = (article[0].querySelectorAll('header > div > div > div > div > span > a')[0] as HTMLLinkElement).href
} else {
userProfileUrl = (article.querySelectorAll('header > div > div > div > div > span > a')[0] as HTMLLinkElement).href;
userProfileUrl = (article.querySelectorAll('header > div > div > div > div > span > a')[0] as HTMLLinkElement).href
}

if (process.env.DEV) {
console.log(['getBlobVideoUrl(): userProfileUrl', userProfileUrl]);
console.log(['getBlobVideoUrl(): userProfileUrl', userProfileUrl])
}

let userProfileUrlResponseData = await getDataFromUrl(userProfileUrl);
let userProfileUrlResponseData = await getDataFromUrl(userProfileUrl)
if (userProfileUrlResponseData) {
userProfileUrlResponseData = userProfileUrlResponseData.replace(/(\r\n|\n|\r)/gm, '');
userProfileUrlResponseData = userProfileUrlResponseData.replace(/(\r\n|\n|\r)/gm, '')

let m;
let regex = /profilePage_([0-9]+)/gm;
let m
let regex = /profilePage_([0-9]+)/gm
while ((m = regex.exec(userProfileUrlResponseData)) !== null) {
/* This is necessary to avoid infinite loops with zero-width matches */
if (m.index === regex.lastIndex) {
regex.lastIndex++;
regex.lastIndex++
}

/* The result can be accessed through the `m`-variable. */
m.forEach((match) => {
userId = match;
userId = match
})
}
}

if (process.env.DEV) {
console.log(['getBlobVideoUrl(): userId', userId])
}

/* Step 2 */
/* Fetch the user data until the file name is found */
let videoUrl = null;
let videoUrl = null
if (userId) {
let userMediaFeedResponseData = await getDataFromUrl('https://www.instagram.com/graphql/query/?query_hash=003056d32c2554def87228bc3fd9668a&variables={"id":' + userId + ',"first":100}');
let userMediaFeedResponseData = await getDataFromUrl(`https://www.instagram.com/graphql/query/?query_hash=003056d32c2554def87228bc3fd9668a&variables={"id":${userId},"first":100}`)
if (process.env.DEV) {
console.log(['getBlobVideoUrl(): userMediaFeedResponseData', JSON.parse(userMediaFeedResponseData)])
}

if (userMediaFeedResponseData) {
let json = JSON.parse(userMediaFeedResponseData);
let json = JSON.parse(userMediaFeedResponseData)

for (let _fI = 0; _fI < json.data.user.edge_owner_to_timeline_media.edges.length; _fI++) {
if (!isMultiVideo) {
if (json.data.user.edge_owner_to_timeline_media.edges[_fI].node.__typename == 'GraphVideo') {
let GraphVideoNode = json.data.user.edge_owner_to_timeline_media.edges[_fI].node;
if (videoPosterFilename == GraphVideoNode.display_url.split('/').pop().split('#')[0].split('?')[0]) {
videoUrl = GraphVideoNode.video_url;
/* Multi Post which can have a video */
if (isMultiVideo) {
if (json.data.user.edge_owner_to_timeline_media.edges[_fI].node.__typename == 'GraphSidecar') {
if (json.data.user.edge_owner_to_timeline_media.edges[_fI].node.hasOwnProperty('edge_sidecar_to_children')) {
let GraphSidecarNode = json.data.user.edge_owner_to_timeline_media.edges[_fI].node.edge_sidecar_to_children.edges[pos].node
videoUrl = GraphSidecarNode.video_url

/* There exists only one node so break it no need to further analyze */
break;
break
}
}
/* Multi Post which can have a video */
} else {
if (json.data.user.edge_owner_to_timeline_media.edges[_fI].node.__typename == 'GraphSidecar') {
if (json.data.user.edge_owner_to_timeline_media.edges[_fI].node.hasOwnProperty('edge_sidecar_to_children')) {
let GraphSidecarNode = json.data.user.edge_owner_to_timeline_media.edges[_fI].node.edge_sidecar_to_children.edges[pos].node;
videoUrl = GraphSidecarNode.video_url;
if (json.data.user.edge_owner_to_timeline_media.edges[_fI].node.__typename == 'GraphVideo') {
let GraphVideoNode = json.data.user.edge_owner_to_timeline_media.edges[_fI].node
console.log(GraphVideoNode.display_url.split('/').pop().split('#')[0].split('?')[0])
if (videoPosterFilename == GraphVideoNode.display_url.split('/').pop().split('#')[0].split('?')[0]) {
videoUrl = GraphVideoNode.video_url

break;
/* There exists only one node so break it no need to further analyze */
break
}
}
}
}
}
}

callback(videoUrl ? videoUrl : null);
callback(videoUrl ? videoUrl : null)
} else {
callback(null);
callback(null)
}
}
export default getBlobVideoUrl;
export default getBlobVideoUrl
60 changes: 30 additions & 30 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,45 +36,45 @@ if (process.env.DEV) {
if (program.regexHostname.test(program.hostname)) {

new MediaScanner().execute(program, function (scannerFound: boolean, scannerProgram: Program) {
if (process.env.DEV) {
if (process.env.DEV) {
console.log('scannerFound', scannerFound);
}

program.foundVideo = scannerProgram.foundVideo;
program.foundImage = scannerProgram.foundImage;
program.foundByModule = scannerProgram.foundByModule;

if (scannerFound == false) {
// Profile page -> instagram.com/instagram/
if (scannerProgram.regexProfilePath.test(scannerProgram.path)) {
new ProfilePageDownload().execute(scannerProgram, function (profilePageDownload: boolean, profilePageDownloadProgram: Program) {
if (process.env.DEV) {
console.log('profilePageDownload', profilePageDownload);
}
// if (scannerFound == false) {
// Profile page -> instagram.com/instagram/
// if (scannerProgram.regexProfilePath.test(scannerProgram.path)) {
// new ProfilePageDownload().execute(scannerProgram, function (profilePageDownload: boolean, profilePageDownloadProgram: Program) {
// if (process.env.DEV) {
// console.log('profilePageDownload', profilePageDownload);
// }

program.foundImage = profilePageDownloadProgram.foundImage;
program.foundProfile = profilePageDownloadProgram.foundProfile;
program.foundVideo = profilePageDownloadProgram.foundVideo;
program.foundByModule = profilePageDownloadProgram.foundByModule;
// program.foundImage = profilePageDownloadProgram.foundImage;
// program.foundProfile = profilePageDownloadProgram.foundProfile;
// program.foundVideo = profilePageDownloadProgram.foundVideo;
// program.foundByModule = profilePageDownloadProgram.foundByModule;

if (profilePageDownload == false && program.foundProfile) {
new Modal({
heading: [
`<h5>[instantgram] <span style="float:right">v${profilePageDownloadProgram.VERSION}</span></h5>`
],
content: [
localize('index#program#profilePageDownload@cannot_download')
],
contentStyle: 'text-align:center',
buttonList: [{
active: true,
text: 'Ok'
}]
}).open();
}
});
}
}
// if (profilePageDownload == false && program.foundProfile) {
// new Modal({
// heading: [
// `<h5>[instantgram] <span style="float:right">v${profilePageDownloadProgram.VERSION}</span></h5>`
// ],
// content: [
// localize('index#program#profilePageDownload@cannot_download')
// ],
// contentStyle: 'text-align:center',
// buttonList: [{
// active: true,
// text: 'Ok'
// }]
// }).open();
// }
// });
// }
// }

if (program.foundByModule == undefined) {
if (process.env.DEV) {
Expand Down
Loading

0 comments on commit 3f09935

Please sign in to comment.