Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions counters/User Card by Belikhun/user-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ const UserCardPanel = {
color: g.colour,
playmodes: g.playmodes
})),
expire: Date.now() + (4 * 60 * 60 * 1000),
expire: Date.now() + (5 * 60 * 1000),
};

localStorage.setItem(`user-data-${userId}`, JSON.stringify(data));
Expand Down Expand Up @@ -607,20 +607,29 @@ const UserCardPanel = {
},

async tryFetch(url, {
retries = 3,
retries = 4,
delay = 1000,
timeout = 10000
} = {}) {
const proxies = [
"https://api.codetabs.com/v1/proxy/?quest=",
"https://api.allorigins.win/get?url="
// codetabs had ceased operations on june 30 2026 (https://github.com/jolav/codetabs)
// "https://api.codetabs.com/v1/proxy/?quest=",

"https://api.allorigins.win/get?url=",

// last resort
"https://proxy.belikhun.dev/"
];

for (let attempt = 1; attempt <= retries; attempt++) {
try {
const proxy = proxies[(attempt - 1) % proxies.length];
const proxiedUrl = proxy + encodeURIComponent(url);
const response = await fetch(proxiedUrl, { timeout }).then(res => res.json());

if (proxy.includes("allorigins"))
return JSON.parse(response.contents);

return response;
} catch (error) {
console.warn(`Fetch attempt ${attempt} failed:`, error);
Expand Down