Created
June 9, 2022 05:00
-
-
Save wesleybliss/19bff81d3abacaed87cffeb08d5c8f97 to your computer and use it in GitHub Desktop.
untitled
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
(async function() { | |
const cls1 = [ | |
'article[role="presentation"]', | |
'div[style]', | |
'div[style]', | |
'div[role="button"]', | |
'div', | |
'div[role="button"]', | |
'div[style]', | |
'img[crossorigin="anonymous"][class]', | |
].join(' > '); | |
const cls2 = [ | |
'#mount_0_0_q6', | |
'div', | |
'div:nth-child(1)', | |
'div', | |
'div.rq0escxv.l9j0dhe7.du4w35lb', | |
'div', | |
'div', | |
'div.j83agx80.cbu4d94t.d6urw2fd.dp1hu0rb.l9j0dhe7.du4w35lb', | |
'div._a3gq', | |
'section', | |
'main', | |
'div._aa6b._aa6d', | |
'div._aa6e', | |
'article', | |
'div', | |
'div._aatk._aatn', | |
'div', | |
'div', | |
'div._aagu._aa20', | |
'div._aagv', | |
'img' | |
].join(' > '); | |
const cls3 = [ | |
'#mount_0_0_iL', | |
'div', | |
'div:nth-child(1)', | |
'div', | |
'div:nth-child(4)', | |
'div', | |
'div', | |
'div.rq0escxv.l9j0dhe7.du4w35lb', | |
'div', | |
'div.iqfcb0g7.tojvnm2t.a6sixzi8.k5wvi7nf.q3lfd5jv.pk4s997a.bipmatt0.cebpdrjk.qowsmv63.owwhemhu.dp1hu0rb.dhp61c6y.l9j0dhe7.iyyx5f41.a8s20v7p', | |
'div', | |
'div', | |
'div', | |
'div', | |
'div.pi61vmqs.od1n8kyl.h6an9nv3.j4yusqav.djyw54ux.c9k30104.rxghi256.jhx0qe0y.mbxd2wpa.hb7lyos6.rfyvs5rk.sspdcydq.n34oi56o.c3wyshyw.im6prb7w.kzdz7bm1.k01ojvdi.alxbew3a.t78t6opn', | |
'div', | |
'article', | |
'div', | |
'div._aatk._aatl._aatm', | |
'div', | |
'div._aamn', | |
'div._ab8w._ab94._ab99._ab9f._ab9m._ab9p._abcf._abcg._abch._abck._abcl', | |
'div', | |
'div', | |
'div', | |
'ul', | |
'li:nth-child(2)', | |
'div', | |
'div', | |
'div', | |
'div._aagv', | |
'img' | |
].join(' > '); | |
const cls4 = [ | |
'#mount_0_0_vg', | |
'div', | |
'div:nth-child(1)', | |
'div', | |
'div:nth-child(4)', | |
'div', | |
'div', | |
'div.rq0escxv.l9j0dhe7.du4w35lb', | |
'div', | |
'div.iqfcb0g7.tojvnm2t.a6sixzi8.k5wvi7nf.q3lfd5jv.pk4s997a.bipmatt0.cebpdrjk.qowsmv63.owwhemhu.dp1hu0rb.dhp61c6y.l9j0dhe7.iyyx5f41.a8s20v7p', | |
'div', | |
'div', | |
'div', | |
'div', | |
'div.pi61vmqs.od1n8kyl.h6an9nv3.j4yusqav.djyw54ux.c9k30104.rxghi256.jhx0qe0y.mbxd2wpa.hb7lyos6.rfyvs5rk.sspdcydq.n34oi56o.c3wyshyw.im6prb7w.kzdz7bm1.k01ojvdi.alxbew3a.t78t6opn', | |
'div', | |
'article', | |
'div', | |
'div._aatk._aatl._aatm', | |
'div', | |
'div', | |
'div._aagv', | |
'img' | |
].join(' > '); | |
const dl = (src, ext, type) => { | |
const link = document.createElement('a') | |
const filename = Date.now() + '_instagram.' + ext; | |
link.href = src; | |
link.type = type; | |
link.target = '_blank'; | |
link.download = filename; | |
link.style.display = 'none'; | |
document.body.appendChild(link); | |
link.click(); | |
document.body.removeChild(link); | |
window.URL.revokeObjectURL(src); | |
}; | |
const qs = q => document.querySelector(q); | |
const iurl = async () => { | |
const el = qs(cls1) || qs(cls2) || qs(cls3) || qs(cls4); | |
if (!el || !el.src) { | |
console.error('Could not find image in either path', JSON.stringify([cls1, cls2, cls3, cls4], null, 4)); | |
return alert('Could not find image'); | |
} | |
const res = await fetch(el.src); | |
const data = await res.blob(); | |
if (!data.size || !data.type) return alert('Failed to download image'); | |
return URL.createObjectURL(data); | |
} | |
const url = await iurl(); | |
if (url) return dl(url, 'jpg', 'img/jpeg'); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment