@@ -83,3 +83,53 @@ function copyBadgeURL(event, url) {
8383 } , 2000 ) ;
8484 } ) ;
8585}
86+
87+ // GitHub API function to fetch latest release
88+ async function fetchLatestGitHubTag ( ) {
89+ try {
90+ // Extract owner and repo from the page
91+ const repoLinks = document . querySelectorAll ( 'a[href*="github.com"]' ) ;
92+ if ( repoLinks . length === 0 ) return null ;
93+
94+ const repoUrl = repoLinks [ 0 ] . href ;
95+ const match = repoUrl . match ( / g i t h u b \. c o m \/ ( [ ^ \/ ] + ) \/ ( [ ^ \/ ] + ) / ) ;
96+ if ( ! match ) return null ;
97+
98+ const [ , owner , repo ] = match ;
99+
100+ // Fetch latest release from GitHub API
101+ const response = await fetch ( `https://api.github.com/repos/${ owner } /${ repo } /releases/latest` ) ;
102+ if ( ! response . ok ) return null ;
103+
104+ const release = await response . json ( ) ;
105+ return {
106+ tag : release . tag_name ,
107+ url : release . html_url
108+ } ;
109+ } catch ( error ) {
110+ console . warn ( 'Failed to fetch latest GitHub tag:' , error ) ;
111+ return null ;
112+ }
113+ }
114+
115+ // Update version display in footer
116+ function updateVersionDisplay ( tagInfo ) {
117+ if ( ! tagInfo ) return ;
118+
119+ const versionLink = document . querySelector ( '.version-link' ) ;
120+ const versionText = document . querySelector ( '.version-text' ) ;
121+
122+ if ( versionLink && versionText ) {
123+ versionLink . href = tagInfo . url ;
124+ versionText . textContent = tagInfo . tag ;
125+ }
126+ }
127+
128+ // Initialize dynamic version update on page load
129+ document . addEventListener ( 'DOMContentLoaded' , async ( ) => {
130+ // Only update if there's a version element present
131+ if ( document . querySelector ( '.version-text' ) ) {
132+ const latestTag = await fetchLatestGitHubTag ( ) ;
133+ updateVersionDisplay ( latestTag ) ;
134+ }
135+ } ) ;
0 commit comments