-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathbackground.js
717 lines (616 loc) · 26.1 KB
/
background.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
const keepAlive = (() => {
let interval = null;
return (state) => {
if (state && !interval) {
interval = setInterval(chrome.runtime.getPlatformInfo, 20e3);
if (performance.now() > 20e3) {
chrome.runtime.getPlatformInfo();
}
} else if (!state && interval) {
clearInterval(interval);
interval = null;
}
};
})();
let isRunning = false;
let logs = [];
let teraboxSubdomain = '';
let dailyLimitReached = false;
let coins = 0;
let baseGemMergeDelay = 300;
let maxGemMergeDelay = 30000; // Increased max delay to 30 seconds
let currentGemMergeDelay = baseGemMergeDelay;
let consecutiveTimeouts = 0;
let lastTimeoutTime = 0;
let successfulRequestsCount = 0;
let timeoutPattern = [];
let globalLogCount = 0
function addLog(message) {
const timestamp = new Date().toLocaleTimeString();
globalLogCount++
logs.push(`${globalLogCount} : [${timestamp}] ${message}`);
if (logs.length > 100) {
logs.shift();
}
chrome.runtime.sendMessage({action: 'logUpdated'}).catch(console.error);
}
chrome.runtime.onInstalled.addListener(() => {
chrome.storage.local.set({ isRunning: false, dailyLimitReached: false }).catch(console.error);
});
chrome.runtime.onStartup.addListener(() => {
keepAlive(true);
});
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
switch (request.action) {
case 'startCollecting':
if (!isRunning && !dailyLimitReached) {
isRunning = true;
addLog('Started coin collection process');
checkRedirect().then((subdomain) => {
teraboxSubdomain = subdomain;
collectCoins();
});
sendResponse({ success: true });
} else {
sendResponse({ success: false, message: dailyLimitReached ? 'Daily limit reached' : 'Already running' });
}
break;
case 'stopCollecting':
isRunning = false;
addLog('Stopped coin collection process');
sendResponse({ success: true });
break;
case 'getStatus':
sendResponse({ isRunning: isRunning, dailyLimitReached: dailyLimitReached });
break;
case 'getLogs':
sendResponse(logs);
break;
case 'getUserInfoAndCoinCount':
getUserInfoAndCoinCount()
.then(data => sendResponse(data))
.catch(error => sendResponse({error: error.message}));
return true;
case 'loadEmbeddedPage':
loadEmbeddedPage(request.url, sender.tab.id);
break;
}
return true;
});
async function loadEmbeddedPage(url, tabId) {
try {
const response = await fetch(url, { credentials: 'include' });
const text = await response.text();
chrome.tabs.sendMessage(tabId, {
action: 'updateEmbeddedContent',
content: text
});
} catch (error) {
console.error('Error loading embedded content:', error);
chrome.tabs.sendMessage(tabId, {
action: 'updateEmbeddedContent',
content: 'Error loading content. Please try again.'
});
}
}
chrome.declarativeNetRequest.updateDynamicRules({
removeRuleIds: [1],
addRules: [{
id: 1,
priority: 1,
action: {
type: 'modifyHeaders',
responseHeaders: [
{ header: 'X-Frame-Options', operation: 'remove' },
{ header: 'Frame-Options', operation: 'remove' }
]
},
condition: {
urlFilter: '*://*.terabox.com/*',
resourceTypes: ['sub_frame']
}
}]
});
async function getTeraboxCookies() {
return new Promise((resolve) => {
chrome.cookies.getAll({ domain: 'terabox.com' }, (cookies) => {
resolve(cookies);
});
});
}
async function checkRedirect() {
try {
const cookies = await getTeraboxCookies();
const cookieString = cookies.map(cookie => `${cookie.name}=${cookie.value}`).join('; ');
const response = await fetch('https://www.terabox.com', {
method: 'GET',
redirect: 'follow',
credentials: 'include',
headers: {
'Cookie': cookieString
}
});
const finalUrl = response.url;
const url = new URL(finalUrl);
teraboxSubdomain = url.hostname.split('.')[0];
addLog(`Redirected to: ${finalUrl}`);
addLog(`Using subdomain: ${teraboxSubdomain}`);
return teraboxSubdomain;
} catch (error) {
addLog(`Error checking redirect: ${error.message}`);
return '';
}
}
async function collectCoins() {
try {
keepAlive(true); // Added this line
while (isRunning) {
try {
// Get extra 80 bonus coins first
addLog('Requesting bonus coins...');
const bonusResponse = await fetchWithRetry(getTeraboxUrl('/rest/1.0/imact/goldrain/report?&valid_envelope_cnt=80'));
if (bonusResponse.errno === 0) {
addLog('Successfully collected bonus coins');
}
addLog('Starting a coin collection cycle...');
const minerInfo = await fetchWithRetry(getTeraboxUrl('/rest/1.0/imact/miner/pull'));
let minerData = { errno: 0, data: minerInfo.data, coins: coins };
do {
minerData = await runGame(minerData.data, minerData.coins);
} while (minerData.errno == 0 && minerData.data.buy_times_left > 0);
if (minerData.errno === -1) {
addLog('Miner game completed. Starting GemMerge game...');
await playGemMergeGame();
// Instead of stopping, continue the cycle
addLog('Game cycle completed. Starting next cycle...');
continue;
}
addLog('Games cycle completed');
chrome.runtime.sendMessage({ action: 'updateCoinCount' }).catch(console.error);
const nextCycleDelay = 5000 + Math.random() * 5000;
addLog(`Waiting ${Math.round(nextCycleDelay / 1000)} seconds before next cycle...`);
await delay(nextCycleDelay);
} catch (error) {
addLog(`Error during games cycle: ${error.message}`);
await delay(10000);
}
}
} finally {
keepAlive(false); // Added this line
}
}
async function runGame(minerInfo, coins) {
minerInfo.buy_times_left -= 51;
addLog(`Free Times Left: ${minerInfo.free_times_left}`);
addLog(`Play Times Left: ${minerInfo.buy_times_left} (Price: ${minerInfo.price} coins)`);
if (minerInfo.free_times_left > 0 || (minerInfo.buy_times_left > 0 && coins > minerInfo.price)) {
await delay(1000);
coins -= minerInfo.price;
const minerStart = await fetchWithRetry(getTeraboxUrl('/rest/1.0/imact/miner/start'));
if (minerStart.errno != 0) {
addLog(`Miner Error: ${JSON.stringify(minerStart)}`);
return { errno: minerStart.errno, data: {}, coins };
}
const rDate = Date.now();
addLog(`Miner Start: GAME #${minerStart.data.game_id}`);
const { game_id, map_info: { items } } = minerStart.data;
const getItemPrefixUrl = `/rest/1.0/imact/miner/getitem?game_id=${game_id}`;
const objectTypes = items.map(item => item.object_type);
for (const objectType of objectTypes) {
if (objectType === 0 || objectType === 10) {
continue;
}
const reportId = Date.now();
const getItemUrl = `${getItemPrefixUrl}&object_type=${objectType}&report_id=${reportId}`;
const getItemData = await fetchWithRetry(getTeraboxUrl(getItemUrl));
if (getItemData.errno == 0 && getItemData.data) {
parseReward(getItemData.data?.result);
} else {
addLog(`Get Item ERROR: ${JSON.stringify(getItemData)}`);
}
await delay(2000 + Math.floor(Math.random() * 100) + 1);
}
const pausingTimer = (rDate + 60000) - Date.now();
addLog(`Ending Game in ${pausingTimer} ms...`);
await delay(pausingTimer);
const finishGameUrl = `/rest/1.0/imact/miner/finishgame?game_id=${game_id}`;
const minerFinish = await fetchWithRetry(getTeraboxUrl(finishGameUrl));
if (minerFinish.errno == 0) {
addLog('Game Ended. Results:');
const rewards = minerFinish.data.rewards;
for (const reward of rewards) {
parseReward(reward);
if (reward.reward_kind == 9) {
coins += reward.size;
}
}
if (rewards.length == 1 && rewards[0].reward_kind == 3 && rewards[0].size == 34603008) {
addLog('Note: No good rewards in next game, quit playing game...');
return { errno: -1, data: {}, coins };
}
} else {
addLog(`Game Results: ${minerFinish.errno} ${JSON.stringify(minerFinish.data)}`);
}
return { errno: minerFinish.errno, data: minerFinish.data, coins };
} else {
return { errno: -1, data: {}, coins };
}
}
async function playGemMergeGame() {
// Reset delay management stats at start of game
currentGemMergeDelay = baseGemMergeDelay;
consecutiveTimeouts = 0;
successfulRequestsCount = 0;
timeoutPattern = [];
lastTimeoutTime = 0;
try {
// Try to retrieve stored game state
const gameState = await new Promise(resolve => {
chrome.storage.local.get(['gemMergeState'], result => {
resolve(result.gemMergeState || null);
});
});
let gameId;
let currentLevel;
// Check if we have a stored game and if it's still valid
if (gameState) {
addLog('Attempting to resume previous game session...');
// Verify the stored game is still valid
const userData = await fetchWithRetry(getTeraboxUrl('/mergegame/getUserData'), {
method: 'POST',
body: JSON.stringify({"snsid": "game2"})
});
await adaptiveDelay();
if (userData.data?.gameid === gameState.gameId) {
gameId = gameState.gameId;
currentLevel = gameState.level;
addLog(`Resumed game ID: ${gameId} at level ${currentLevel}`);
} else {
addLog('Stored game is no longer valid, starting new game...');
gameId = null;
currentLevel = 2;
}
} else {
currentLevel = 2;
}
// Start new game if we don't have a valid stored game
if (!gameId) {
currentLevel = 2;
let gameResponse;
try {
gameResponse = await fetchWithRetry(getTeraboxUrl('/mergegame/getGameReward'), {
method: 'POST',
body: JSON.stringify({"gameid": 0, "level": currentLevel, "isFreeGame": 0})
});
addLog('Started new GemMerge game (paid version)');
} catch (error) {
addLog('Paid version failed, trying free version...');
await adaptiveDelay();
gameResponse = await fetchWithRetry(getTeraboxUrl('/mergegame/getGameReward'), {
method: 'POST',
body: JSON.stringify({"gameid": 0, "level": currentLevel, "isFreeGame": 1})
});
addLog('Started new GemMerge game (free version)');
}
if (!gameResponse.data?.gameid) {
throw new Error('Failed to get valid game ID');
}
gameId = gameResponse.data.gameid;
addLog(`Game ID: ${gameId}`);
parseGemMergeRewards(gameResponse.data?.rewards, 'Initial rewards');
}
// Store initial/resumed game state
await saveGameState(gameId, currentLevel);
// Play levels
for (let level = currentLevel; level <= 100; level++) {
if (!isRunning) {
addLog('Game stopped by user');
await saveGameState(gameId, level);
break;
}
for (let attempt = 0; attempt < 2; attempt++) {
try {
addLog(`Attempting level ${level} with ${Math.round(currentGemMergeDelay)}ms base delay...`);
// Send level up request
const levelUpResponse = await fetchWithRetry(getTeraboxUrl('/mergegame/sendGameLevelup'), {
method: 'POST',
body: JSON.stringify({
"level": level,
"isad": false,
"gameid": gameId
})
});
if (levelUpResponse.errno === 0) {
addLog(`Successfully completed level ${level}`);
} else {
throw new Error(`Level up failed with errno: ${levelUpResponse.errno}`);
}
await adaptiveDelay();
// Get rewards for next level
const rewardResponse = await fetchWithRetry(getTeraboxUrl('/mergegame/getGameReward'), {
method: 'POST',
body: JSON.stringify({
"gameid": gameId,
"level": level + 1,
"isFreeGame": 1
})
});
if (rewardResponse.errno === 0) {
parseGemMergeRewards(rewardResponse.data?.rewards, `Level ${level + 1} rewards`);
} else {
throw new Error(`Failed to get rewards with errno: ${rewardResponse.errno}`);
}
await adaptiveDelay();
// Mark rewards as received
const gotRewardResponse = await fetchWithRetry(getTeraboxUrl('/mergegame/hasgotReward'), {
method: 'POST',
body: JSON.stringify({"gameid": gameId})
});
if (gotRewardResponse.errno !== 0) {
addLog(`Warning: hasgotReward returned errno: ${gotRewardResponse.errno}`);
}
// Update stored state after successful level completion
await saveGameState(gameId, level + 1);
// If we got here, level was successful
break;
} catch (error) {
if (attempt === 1) {
addLog(`Failed to complete level ${level} after 2 attempts: ${error.message}`);
await delay(currentGemMergeDelay * 2);
} else {
await adaptiveDelay();
}
}
}
// Check if we've reached level 100
if (level === 100) {
addLog('Reached level 100! Completing final rewards and restarting...');
// Get final reward for this game session
try {
const finalReward = await fetchWithRetry(getTeraboxUrl('/mergegame/getTotalReward'), {
method: 'POST',
body: JSON.stringify({"gameid": gameId})
});
if (finalReward.errno === 0) {
parseGemMergeRewards(finalReward.data?.rewards, 'Final game rewards');
addLog('GemMerge game session completed successfully');
// Clear stored game state
await clearGameState();
// Return to let the collectCoins function start a new cycle
return;
} else {
addLog(`Warning: Final rewards returned errno: ${finalReward.errno}`);
}
} catch (error) {
addLog(`Error getting final rewards: ${error.message}`);
}
}
// Add delay between levels
await adaptiveDelay();
}
} catch (error) {
addLog(`Error in GemMerge game: ${error.message}`);
addLog(`Final delay settings - Delay: ${Math.round(currentGemMergeDelay)}ms, Consecutive timeouts: ${consecutiveTimeouts}`);
throw error;
} finally {
// Log final statistics
addLog(`Game session ended. Final delay: ${Math.round(currentGemMergeDelay)}ms`);
// Reset delays for next session
currentGemMergeDelay = baseGemMergeDelay;
consecutiveTimeouts = 0;
}
}
// Add this new helper function
function adaptiveDelay() {
const now = Date.now();
const jitter = Math.random() * 200; // Increased jitter range
// Add pattern detection
if (timeoutPattern.length >= 5) {
timeoutPattern.shift();
}
timeoutPattern.push(now);
// Check for pattern in timeouts
if (timeoutPattern.length >= 3) {
const intervals = [];
for (let i = 1; i < timeoutPattern.length; i++) {
intervals.push(timeoutPattern[i] - timeoutPattern[i-1]);
}
// If we detect a regular pattern, adjust base delay
const avgInterval = intervals.reduce((a, b) => a + b, 0) / intervals.length;
const patternDetected = intervals.every(interval =>
Math.abs(interval - avgInterval) < 1000
);
if (patternDetected) {
currentGemMergeDelay = Math.min(maxGemMergeDelay, avgInterval * 1.2);
addLog(`Pattern detected - Adjusting base delay to ${Math.round(currentGemMergeDelay)}ms`);
}
}
// Dynamic delay calculation
let finalDelay = currentGemMergeDelay;
// If we had a recent timeout, increase delay more aggressively
if (now - lastTimeoutTime < 60000) { // Within last minute
finalDelay *= (1 + (consecutiveTimeouts * 0.5));
}
// Add success-based reduction
if (successfulRequestsCount > 5) {
finalDelay *= Math.max(0.7, 1 - (successfulRequestsCount * 0.05));
}
// Add jitter and ensure within bounds
finalDelay = Math.min(maxGemMergeDelay, Math.max(baseGemMergeDelay, finalDelay + jitter));
addLog(`Waiting ${Math.round(finalDelay)}ms before next request... (Success streak: ${successfulRequestsCount})`);
return delay(finalDelay);
}
// Helper function to save game state
async function saveGameState(gameId, level) {
return new Promise(resolve => {
chrome.storage.local.set({
gemMergeState: {
gameId: gameId,
level: level,
timestamp: Date.now()
}
}, resolve);
});
}
// Helper function to clear game state
async function clearGameState() {
return new Promise(resolve => {
chrome.storage.local.remove('gemMergeState', resolve);
});
}
function parseGemMergeRewards(rewards, context = 'Rewards') {
if (!rewards || !Array.isArray(rewards)) {
addLog(`${context}: No rewards received`);
return;
}
addLog(`${context}:`);
let totalCoins = 0;
let totalStorage = 0;
let totalPremiumDays = 0;
rewards.forEach(reward => {
switch (reward.RewardType) {
case 9: // Coins
totalCoins += reward.RewardCount;
addLog(`- ${reward.RewardCount} coins (${reward.ADTimes} ads available)`);
break;
case 3: // Storage
totalStorage += reward.RewardCount;
addLog(`- ${formatFileSize(reward.RewardCount)} storage (${reward.ADTimes} ads available)`);
break;
case 8: // Premium
totalPremiumDays += reward.RewardCount;
addLog(`- ${reward.RewardCount} premium days (${reward.ADTimes} ads available)`);
break;
default:
addLog(`- Unknown reward type ${reward.RewardType}: ${reward.RewardCount} (${reward.ADTimes} ads available)`);
}
});
if (totalCoins > 0 || totalStorage > 0 || totalPremiumDays > 0) {
addLog('Total rewards received:');
if (totalCoins > 0) addLog(`- Total coins: ${totalCoins}`);
if (totalStorage > 0) addLog(`- Total storage: ${formatFileSize(totalStorage)}`);
if (totalPremiumDays > 0) addLog(`- Total premium days: ${totalPremiumDays}`);
}
}
function formatFileSize(bytes) {
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
let size = bytes;
let unitIndex = 0;
while (size >= 1024 && unitIndex < units.length - 1) {
size /= 1024;
unitIndex++;
}
return `${size.toFixed(2)} ${units[unitIndex]}`;
}
function parseReward(rewardData) {
const reward_kind = rewardData?.reward_kind;
switch (reward_kind) {
case 9:
addLog(`Got Coins: ${rewardData.size}`);
break;
case 3:
addLog(`Got Space: ${formatFileSize(rewardData.size)}`);
break;
case 6:
addLog(`Got Catch-up Cards: ${rewardData.size}`);
break;
case 8:
addLog(`Got Premium Days: ${rewardData.size}`);
break;
default:
addLog(`Got Item: ${JSON.stringify(rewardData)}`);
}
}
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function fetchWithRetry(url, options = {}, retries = 3) {
try {
const cookies = await getTeraboxCookies();
const cookieString = cookies.map(cookie => `${cookie.name}=${cookie.value}`).join('; ');
const headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Cookie': cookieString,
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36'
};
const response = await fetch(url, {
method: options.method || 'GET',
credentials: 'include',
headers: headers,
body: options.body,
...options
});
const data = await response.json();
// Success handling
if (url.includes('/mergegame/')) {
successfulRequestsCount++;
if (consecutiveTimeouts > 0) {
consecutiveTimeouts--;
// Gradual delay reduction on success
currentGemMergeDelay = Math.max(
baseGemMergeDelay,
currentGemMergeDelay * Math.pow(0.9, Math.min(successfulRequestsCount, 5))
);
}
}
return data;
} catch (error) {
if (retries > 0) {
// Timeout/error handling
if (url.includes('/mergegame/')) {
lastTimeoutTime = Date.now();
consecutiveTimeouts++;
successfulRequestsCount = 0;
// Exponential backoff with timeout count consideration
const backoffFactor = 1.5 + (Math.min(consecutiveTimeouts, 5) * 0.2);
currentGemMergeDelay = Math.min(
maxGemMergeDelay,
currentGemMergeDelay * backoffFactor
);
addLog(`Request failed. Increased delay to ${Math.round(currentGemMergeDelay)}ms (Consecutive timeouts: ${consecutiveTimeouts})`);
}
addLog(`Fetch failed, retrying... (${retries} attempts left)`);
await adaptiveDelay();
return fetchWithRetry(url, options, retries - 1);
}
throw error;
}
}
function getTeraboxUrl(path) {
return `https://${teraboxSubdomain || 'www'}.terabox.com${path}`;
}
async function getUserInfoAndCoinCount() {
try {
const userInfoUrl = getTeraboxUrl('/passport/get_info');
const userInfoResponse = await fetchWithRetry(userInfoUrl);
const coinCountUrl = getTeraboxUrl('/rest/1.0/inte/system/getrecord');
const coinCountResponse = await fetchWithRetry(coinCountUrl);
coins = coinCountResponse.data.can_used_cnt;
return {
userInfo: userInfoResponse,
coinCount: coinCountResponse
};
} catch (error) {
addLog(`Error fetching user info and coin count: ${error.message}`);
throw error;
}
}
// Reset daily limit at midnight
function scheduleResetDailyLimit() {
const now = new Date();
const night = new Date(
now.getFullYear(),
now.getMonth(),
now.getDate() + 1, // the next day
0, 0, 0 // at 00:00:00 hours
);
const msToMidnight = night.getTime() - now.getTime();
setTimeout(() => {
dailyLimitReached = false;
chrome.storage.local.set({ dailyLimitReached: false }).catch(console.error);
addLog('Daily limit has been reset.');
scheduleResetDailyLimit(); // Schedule the next reset
}, msToMidnight);
}
scheduleResetDailyLimit()