MCPcopy Create free account
hub / github.com/ShafiqSadat/HamsterKeyGenWeb / generateKeyProcess

Function generateKeyProcess

script.js:279–307  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

277 };
278
279 const generateKeyProcess = async () => {
280 const clientId = generateClientId();
281 let clientToken;
282 try {
283 clientToken = await login(clientId, game.appToken);
284 } catch (error) {
285 alert(`Failed to login: ${error.message}`);
286 startBtn.disabled = false;
287 return null;
288 }
289
290 for (let i = 0; i < game.attempts; i++) {
291 const hasCode = await emulateProgress(clientToken, game.promoId);
292 updateProgress((100 / game.attempts) / keyCount, `Emulating progress ${i + 1}/${game.attempts}...`);
293 if (hasCode) {
294 break;
295 }
296 await sleep(game.timing); // Sleep after each attempt to wait before the next event registration
297 }
298
299 try {
300 const key = await generateKey(clientToken, game.promoId);
301 updateProgress(100 / keyCount, 'Generating key...');
302 return key;
303 } catch (error) {
304 alert(`Failed to generate key: ${error.message}`);
305 return null;
306 }
307 };
308
309 const keys = await Promise.all(Array.from({ length: keyCount }, generateKeyProcess));
310

Callers

nothing calls this directly

Calls 6

generateClientIdFunction · 0.85
loginFunction · 0.85
emulateProgressFunction · 0.85
updateProgressFunction · 0.85
sleepFunction · 0.85
generateKeyFunction · 0.85

Tested by

no test coverage detected