Skip to content

Instantly share code, notes, and snippets.

@rcaloras
Created January 6, 2023 20:42
Show Gist options
  • Save rcaloras/95bcd4e83cb17ff40d28e8d51fc2e0df to your computer and use it in GitHub Desktop.
Save rcaloras/95bcd4e83cb17ff40d28e8d51fc2e0df to your computer and use it in GitHub Desktop.
Opensea metadata refresh script. For chains that aren't supported via API.
// Paste this script into the console on a specfic NFT detail page for your collection.
// e.g. https://opensea.io/assets/ethereum/0x1485297e942ce64e0870ece60179dfda34b4c625/3723
// Adjust i on the for loop for the range of nfts you wish to refresh
// Should work for all chains including Polygon and testnets.
// Returns a Promise that resolves after "ms" Milliseconds
const timer = ms => new Promise(res => setTimeout(res, ms))
async function refresh_metadata() { // We need to wrap the loop into an async function for this to work
for (var i = 1; i <= 1326; i++) {
await timer(1000); // then the created Promise can be awaited
var collectionUrl = window.location.href.split('/').slice(0, -1).join('/') + '/'
var nextUrl = collectionUrl + i
var nextWindow = window.open(nextUrl)
nextWindow.addEventListener('load', function () {
// Interact with the dom on this new page
kabob = nextWindow.document.getElementsByClassName('sc-a143597d-0 sc-f0199734-0 RovoC gdcSkC material-icons')[2]
kabob.click()
refresh = nextWindow.document.getElementsByClassName('sc-29427738-0 sc-bdnxRM sc-a8df1259-2 erpyI iPAlIP')[0]
refresh.click()
console.log("Refreshed for " + i)
}, false);
nextWindow.blur();
await timer(3000);
nextWindow.close();
}
}
refresh_metadata()
@TomiOhl
Copy link

TomiOhl commented Jul 27, 2023

is this the CONSOLE when accessing developer-tools / web-inspector built in the browser??.. like when right-clicking any webpage in Google Chrome??

Exactly. Just do that while an nft detail page is open since the script works with that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment