@@ -2031,10 +2031,12 @@ <h4>Connect With Us</h4>
20312031
20322032 // GitHub API headers with hardcoded token
20332033 function getApiHeaders ( ) {
2034+ const token = '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' ;
20342035 return {
20352036 'Accept' : 'application/vnd.github.v3+json' ,
20362037 'User-Agent' : 'AnimateItNow-Leaderboard' ,
2037- 'Authorization' : 'token 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'
2038+ // Classic tokens use 'token' prefix
2039+ 'Authorization' : `token ${ token } `
20382040 } ;
20392041 }
20402042
@@ -2064,37 +2066,43 @@ <h4>Connect With Us</h4>
20642066 const remaining = response . headers . get ( 'X-RateLimit-Remaining' ) ;
20652067 const resetTime = response . headers . get ( 'X-RateLimit-Reset' ) ;
20662068
2067- if ( response . status === 403 ) {
2069+ if ( response . status === 401 ) {
2070+ const errorData = await response . json ( ) . catch ( ( ) => ( { } ) ) ;
2071+ throw new Error ( `GitHub API authentication failed (401). Token may be invalid or expired. ${ errorData . message || 'Please check your token.' } ` ) ;
2072+ }
2073+
2074+ if ( response . status === 403 ) {
20682075 if ( resetTime ) {
20692076 const resetDate = new Date ( parseInt ( resetTime ) * 1000 ) ;
20702077 throw new Error ( `GitHub API rate limit exceeded. Please try again after ${ resetDate . toLocaleTimeString ( ) } ` ) ;
2071- }
2078+ }
20722079 throw new Error ( `GitHub API error! Status: ${ response . status } . Rate limit may be exceeded.` ) ;
20732080 }
20742081
20752082 if ( ! response . ok ) {
2076- throw new Error ( `GitHub API error! Status: ${ response . status } ` ) ;
2083+ const errorData = await response . json ( ) . catch ( ( ) => ( { } ) ) ;
2084+ throw new Error ( `GitHub API error! Status: ${ response . status } . ${ errorData . message || '' } ` ) ;
20772085 }
2078-
2079- const data = await response . json ( ) ;
2086+
2087+ const data = await response . json ( ) ;
20802088
20812089 // Check if we have data
20822090 if ( ! Array . isArray ( data ) || data . length === 0 ) {
20832091 break ; // No more pages
20842092 }
2085-
2086- results = results . concat ( data ) ;
2093+
2094+ results = results . concat ( data ) ;
20872095
20882096 // If we got less than 100 items, we're likely on the last page
20892097 if ( data . length < 100 ) {
20902098 break ;
20912099 }
20922100
2093- page ++ ;
2101+ page ++ ;
20942102 } catch ( error ) {
20952103 console . error ( `Error fetching page ${ page } :` , error ) ;
20962104 throw error ;
2097- }
2105+ }
20982106 }
20992107
21002108 return results ;
@@ -2348,16 +2356,16 @@ <h4>Connect With Us</h4>
23482356 const tbody = document . querySelector ( "#pointsTable tbody" ) ;
23492357 if ( tbody ) {
23502358 tbody . innerHTML = `
2351- <tr><td colspan="4" style="text-align: center; padding: 40px;">
2352- <div style="font-size: 3rem; margin-bottom: 20px;">⚠️</div>
2359+ <tr><td colspan="4" style="text-align: center; padding: 40px;">
2360+ <div style="font-size: 3rem; margin-bottom: 20px;">⚠️</div>
23532361 <div style="font-size: 1.2rem; font-weight: 600; color: #dc3545; margin-bottom: 10px;">Error Loading Data</div>
2354- <div style="font-size: 0.9rem; color: var(--text-light); margin-bottom: 20px;">${ error . message } </div>
2362+ <div style="font-size: 0.9rem; color: var(--text-light); margin-bottom: 20px;">${ error . message } </div>
23552363 <button onclick="sessionStorage.removeItem('${ cacheKey } '); location.reload();"
23562364 style="padding: 10px 20px; background: #6C63FF; color: white; border: none; border-radius: 5px; cursor: pointer; margin-top: 10px;">
23572365 Force Retry
23582366 </button>
2359- </td></tr>
2360- ` ;
2367+ </td></tr>
2368+ ` ;
23612369 }
23622370
23632371 // Update stats to show zeros
0 commit comments