-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (41 loc) · 1.44 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// From which Token ID it should start refreshing?
const from = 1;
// Up-to which Token ID it should keep refreshing?
const to = 10;
/* ---------------------------------------- Do not change anything below this comment---------------------------------------------------------- */
const secondsPerItem = 5000;
const timer = (ms) => new Promise((res) => setTimeout(res, ms));
const getElementByXpath = (document, path) => {
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
const refreshMetadata = async () => {
for (let i = from; i <= to; i++) {
await timer(secondsPerItem);
const collectionUrl = window.location.href.split("/").slice(0, -1).join("/") + "/";
const nextUrl = collectionUrl + i;
const nextWindow = window.open(nextUrl);
nextWindow.addEventListener(
"load",
async function () {
moreBtn = getElementByXpath(nextWindow.document, "//button[@aria-label='More']");
if (!moreBtn) {
nextWindow.close();
return;
};
moreBtn.click();
await timer(1000);
refreshBtn = getElementByXpath(nextWindow.document, "//button[contains(., 'Refresh metadata')]");
if (!refreshBtn) {
nextWindow.close();
return;
}
refreshBtn.click();
nextWindow.blur();
await timer(1000);
nextWindow.close();
},
false
);
}
}
refreshMetadata();