Skip to content

Commit

Permalink
🐛 Fixed bugs on main page
Browse files Browse the repository at this point in the history
  • Loading branch information
aashutoshrathi committed Dec 24, 2018
1 parent a066e68 commit 79deeed
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions download.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,24 @@ function injectButtons () {

for (i = 0; i < images.length; i += 1) {
// making the image link a downloading link
images[i].src = `${images[i].src}&dl=1`
if (!images[i].src.endsWith('&dl=1')) {
images[i].src = `${images[i].src}&dl=1`
}
}
// Grab images appearing on the page
// // Grab images appearing on the page
const videos = document.querySelectorAll('video')
// making the video link as downloading dlink
// // making the video link as downloading dlink

if (videos[0]) {
for (i = 0; i < videos.length; i += 1) {
videos[i].src = `${videos[i].src}&dl=1`
if (!videos[i].src.endsWith('&dl=1')) {
videos[i].src = `${videos[i].src}&dl=1`
}
}
}
let j = 0

// Explore Page
if (explore) {
for (i = 3; i < images.length; i += 1) {
const x =
Expand Down Expand Up @@ -114,7 +119,7 @@ function injectButtons () {
}
}
}
} else if (elseProfile) {
} else if (elseProfile) { // Someone else's profile
const dlbutton = document.createElement('a')
dlbutton.innerHTML = `
<a download href=${images[0].src}>
Expand Down Expand Up @@ -202,6 +207,7 @@ function injectButtons () {
}
}
} else {
// Handle main page here
// Iterate through the headers and inject a button to download corresponding image
console.log('%c Main Page', 'background: #222; color: #bada55')
for (i = 0; i < headers.length; i += 1) {
Expand All @@ -216,22 +222,26 @@ function injectButtons () {
images[2 * i + 1].naturalHeight === 150 ||
(videos[j] && videos[j].poster === dlink)
) {
if (videos[j].src) {
/**
* @todo Fix the Video Links in Main Page
* @body For some reason, it gives poster link in current scenario and also order of links are not correct.
*/
if (videos[j] && videos[j].src) {
dlink = videos[j].src
}
j += 1
}

dlbutton.innerHTML = `
<a download href=${dlink}>
<button class="instanshu-unite instanshu-sm instanshu-success">Download</button>`
<button class="instanshu-unite instanshu-sm instanshu-success">Download</button></a>`

pfbutton.innerHTML = `
<a download href=${dplink}>
<button class="instaashu-material-circle instaashu-sm
instaashu-success instaashu-no-outline"
style ="margin-right:10px; padding: 4px 1px;">DP<i class="fas fa-arrow-circle-down"></i>
</button>`
</button></a>`

buttonsParent.appendChild(pfbutton)
buttonsParent.appendChild(dlbutton)
Expand Down

0 comments on commit 79deeed

Please sign in to comment.