Created
August 7, 2020 18:20
-
-
Save pugson/989b58088456eee864e129c906334ae2 to your computer and use it in GitHub Desktop.
bookmarklet to download / get full size media from instagram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function()%7B"use strict"%3Bconst iconDownload%3D'<svg width%3D"24" height%3D"24" viewBox%3D"0 0 512 512"><g><g><path d%3D"M472%2C313v139c0%2C11.028-8.972%2C20-20%2C20H60c-11.028%2C0-20-8.972-20-20V313H0v139c0%2C33.084%2C26.916%2C60%2C60%2C60h392 c33.084%2C0%2C60-26.916%2C60-60V313H472z"><%2Fpath><%2Fg><%2Fg><g><g><polygon points%3D"352%2C235.716 276%2C311.716 276%2C0 236%2C0 236%2C311.716 160%2C235.716 131.716%2C264 256%2C388.284 380.284%2C264"><%2Fpolygon><%2Fg><%2Fg><%2Fsvg>'%2CiconNewtab%3D'<svg width%3D"24" height%3D"24" viewBox%3D"0 0 482.239 482.239"><path d%3D"m465.016 0h-344.456c-9.52 0-17.223 7.703-17.223 17.223v86.114h-86.114c-9.52 0-17.223 7.703-17.223 17.223v344.456c0 9.52 7.703 17.223 17.223 17.223h344.456c9.52 0 17.223-7.703 17.223-17.223v-86.114h86.114c9.52 0 17.223-7.703 17.223-17.223v-344.456c0-9.52-7.703-17.223-17.223-17.223zm-120.56 447.793h-310.01v-310.01h310.011v310.01zm103.337-103.337h-68.891v-223.896c0-9.52-7.703-17.223-17.223-17.223h-223.896v-68.891h310.011v310.01z"><%2Fpath><%2Fsvg>'%3Blet currentUrl%3Ddocument.location.href%2Cupdating%3D!1%3Bfunction init(e)%7Bfor(let t%3D0%3Bt<e%3Bt%2B%2B)setTimeout(addButton%2C500*t)%2CsetTimeout(checkSort%2C500*t)%7Dfunction addButton()%7Bdocument.querySelectorAll("section.ltpMr.Slqrh%3Anot(.section-set)").forEach(e%3D>%7Be.classList.add("section-set")%2C"undefined"!%3Dtypeof InstallTrigger%7C%7CsetButton(e%2C"download-set"%2CiconDownload)%2CsetButton(e%2C"newtab-set"%2CiconNewtab)%7D)%7Dfunction checkSort()%7Bdocument.querySelectorAll("section.ltpMr.Slqrh.section-set").forEach(function(e)%7Bconst t%3De.childElementCount%2Cn%3De.children%5Bt-2%5D%3Bif(!n.className.includes("wpO6b"))return%3Bconst o%3De.querySelector(".dCJp8")%3Be.insertBefore(n%2Co)%7D)%7Dfunction setButton(e%2Ct%2Cn)%7Bconst o%3Ddocument.createElement("button")%3Bo.className%3D%60dCJp8 afkep %24%7Bt%7D%60%2Co.innerHTML%3Dn%2Co.addEventListener("click"%2ConClick)%2Ce.lastElementChild.before(o)%7Dfunction onClick()%7Bconst e%3Dthis.closest(".eo2As").previousElementSibling%2Ct%3D!e.querySelectorAll("._3eoV-.IjCL9").length%2Cn%3De.querySelectorAll(".FFVAD").length%3Fe.querySelectorAll(".FFVAD")%3Ae.querySelectorAll("video")%2Co%3Dt%3Fn%5B0%5D.src%3AdetectIndex(e%2Cn)%3Bdownload(this.className.includes("download")%2Co%2Cthis.closest("article"))%7Dfunction detectIndex(e%2Ct)%7Bconst n%3De.querySelectorAll(".POSa_").length%2Co%3De.querySelectorAll("._6CZji").length%3Breturn!n%26%26o%3Ft%5B0%5D.src%3At%5B1%5D.src%7Dfunction download(e%2Ct%2Cn)%7Bif(e)fetch(t).then(e%3D>e.blob().then(e%3D>%7Bconst t%3Ddocument.createElement("a")%2Co%3D%60%24%7BgetUser(n)%7D_%24%7BgetTime(n)%7D%24%7BgetIndex(n)%7D%60%3Bt.href%3DURL.createObjectURL(e)%2Ct.setAttribute("download"%2Co)%2Ct.click()%7D))%3Belse%7Bwindow.open(t%2C"_blank").focus()%7D%7Dfunction getUser(e)%7Breturn e.querySelector(".e1e1d a").innerText.replace("."%2C"-")%7Dfunction getTime(e)%7Bconst t%3De.querySelector("time").dateTime.split(%2F%5B-%2CT%5D%2F)%3Breturn%60%24%7Bt%5B0%5D%7D%24%7Bt%5B1%5D%7D%24%7Bt%5B2%5D%7D%60%7Dfunction getIndex(e)%7Bconst t%3De.querySelectorAll(".Yi5aA")%3Breturn t.length>1%3F%60-%24%7B%5B...t%5D.findIndex(e%3D>e.classList.contains("XCodT"))%2B1%7D%60%3A""%7Dfunction update()%7Bupdating%7C%7C(updating%3D!0%2Cinit(3)%2CsetTimeout(()%3D>%7Bupdating%3D!1%7D%2C1e3))%7Dfunction locationChange()%7Bconst e%3Dnew MutationObserver(e%3D>%7Be.forEach(()%3D>%7BcurrentUrl!%3Ddocument.location.href%26%26(currentUrl%3Ddocument.location.href%2Cinit(10))%7D)%7D)%2Ct%3Ddocument.querySelector("body")%3Be.observe(t%2C%7BchildList%3A!0%2Csubtree%3A!0%7D)%7Dinit(10)%2ClocationChange()%2Cwindow.addEventListener("scroll"%2Cupdate)%7D)() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment