Skip to content

Commit

Permalink
Fix bug: parse id private profile
Browse files Browse the repository at this point in the history
  • Loading branch information
HOAIAN2 committed May 26, 2023
1 parent cb518d7 commit 0477a53
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/js/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,32 @@ function convertToPostID(shortcode) {
}
return id.toString(10)
}
async function getPostIDFromAPI() {
const apiURL = new URL('/graphql/query/', BASE_URL)
apiURL.searchParams.set('query_hash', POST_HASH)
apiURL.searchParams.set('variables', JSON.stringify({
shortcode: appLog.current.shortcode
}))
try {
const respone = await fetch(apiURL.href)
const json = await respone.json()
return json.data['shortcode_media'].id
} catch (error) {
console.log(error)
return null
}
}
async function getPostPhotos(options) {
const postID = convertToPostID(appLog.current.shortcode)
const apiURL = new URL(`/api/v1/media/${postID}/info/`, BASE_URL)
try {
const respone = await fetch(apiURL.href, options)
let respone = await fetch(apiURL.href, options)
if (respone.status === 400) {
const postID = await getPostIDFromAPI()
if (!postID) throw new Error('Network bug')
const apiURL = new URL(`/api/v1/media/${postID}/info/`, BASE_URL)
respone = await fetch(apiURL.href, options)
}
const json = await respone.json()
return json.items[0]
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions src/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
user-select: none;
-webkit-user-select: none;
transition: 0.5s ease;
z-index: 1000000;
}

.display-container.dark {
Expand Down Expand Up @@ -169,6 +170,7 @@
background-color: var(--violet);
box-shadow: 0px 0px 3px var(--violet);
transition: 0.3s;
z-index: 1000000;
}

.download-button.loading {
Expand Down

0 comments on commit 0477a53

Please sign in to comment.