Last active
June 10, 2022 20:54
-
-
Save caffeinum/a549f1e0d991f3ebfd3c3f710a31196a to your computer and use it in GitHub Desktop.
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
// for https://cloudflare-ipfs.com/ipfs/Qmf3ysov9xRpBJwuCwAGmWT99UwGPV3bjoSo2uQEpfPBWK/pictures listing | |
const LENGTH = 5000 | |
// MANUALLY select temp1 as a <tbody> OR: | |
const tbody = document.querySelector('tbody') | |
const arr = Array(LENGTH + 1).fill(null).reduce((acc, _, index) => [...acc, tbody.children.item(index)], []) | |
// LENGTH can be longer than the number of elements, so we filter null | |
const links = arr.slice(1).reduce((acc, elem) => [ ...acc, elem ? { filename: elem.children.item(1).children.item(0).innerText , url: elem.children.item(2).children.item(0).href } : {} ], []) | |
const sortedLinks = links.sort((l1,l2) => parseInt(l1.filename) - parseInt(l2.filename)) | |
const cleanLinks = sortedLinks.map(l => (l.url = l.url?.replace("https://buildship.mypinata.cloud/ipfs/", "ipfs://"), l)) | |
JSON.stringify(cleanLinks.map(l => l.url)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorting names, filtering filetypes