var dld = {
proxyServer: [
"https://cors.eu.org/",
"https://api.netnr.eu.org/link/",
"https://api.codetabs.com/v1/proxy?quest=",
"https://netnr.zme.ink/api/v1/Proxy?url="
],
proxyIndex: 0,
proxyGet: (link) => {
let ps = dld.proxyServer[dld.proxyIndex++];
if (dld.proxyIndex >= dld.proxyServer.length) {
dld.proxyIndex = 0;
}
return `${ps}${encodeURIComponent(link)}`;
},
checkLinks: document.links,
checkIndex: 0,
checkMax: 6,
checkPending: [],
resultOk: [],
resultBad: [],
init: () => {
dld.start();
},
start: () => {
const link = dld.checkLinks[dld.checkIndex];
const url = dld.proxyGet(link);
const promise = fetch(url).then(resp => {
if (resp.ok) {
dld.resultOk.push(resp);
} else {
dld.resultBad.push(link);
}
}).catch(error => {
dld.resultBad.push(link);
}).finally(() => {
dld.checkPending.splice(dld.checkPending.indexOf(promise), 1);
console.debug(`ok: ${dld.resultOk.length}, bad: ${dld.resultBad.length}, progress: ${(dld.checkIndex + 1) - dld.checkPending.length}/${dld.checkLinks.length}`);
if (dld.checkIndex + 1 == dld.checkLinks.length && dld.checkPending.length == 0) {
console.debug(dld.resultBad.join('\r\n'));
} else if (dld.checkIndex + 1 < dld.checkLinks.length && dld.checkPending.length < dld.checkMax) {
dld.checkIndex++;
dld.start();
}
});
dld.checkPending.push(promise);
if (dld.checkIndex + 1 < dld.checkLinks.length && dld.checkPending.length < dld.checkMax) {
dld.checkIndex++;
dld.start();
}
}
};
dld.init();