@@ -2114,60 +2114,46 @@ <h3>Hardware Recommendations</h3>
21142114
21152115< script >
21162116 document . addEventListener ( 'DOMContentLoaded' , function ( ) {
2117- const owner = 'CPScript' ;
2118- const repo = 'SystemScript' ;
2119- const repoUrl = `https://github.com/${ owner } /${ repo } ` ;
2117+ const headerButtons = document . querySelectorAll ( '.header-button' ) ;
2118+
2119+ let downloadButton = null ;
2120+ let githubButton = null ;
2121+
2122+ headerButtons . forEach ( button => {
2123+ if ( button . textContent . includes ( 'Download' ) ) {
2124+ downloadButton = button ;
2125+ } else if ( button . textContent . includes ( 'GitHub' ) ) {
2126+ githubButton = button ;
2127+ }
2128+ } ) ;
2129+
2130+ const githubRepoUrl = 'https://github.com/CPScript/SystemScript' ;
2131+
2132+ const downloadUrl = 'https://github.com/CPScript/SystemScript/releases/tag/beta-2.0' ;
21202133
2121- const downloadButton = document . querySelector ( '.header-button:first-of-type' ) ;
21222134 if ( downloadButton ) {
21232135 downloadButton . addEventListener ( 'click' , function ( ) {
2124- const originalText = downloadButton . innerHTML ;
2125- downloadButton . innerHTML = '<span class="icon-download"></span> Fetching release...' ;
2126- downloadButton . disabled = true ;
2127-
2128- fetch ( `https://api.github.com/repos/${ owner } /${ repo } /releases/latest` )
2129- . then ( response => {
2130- if ( ! response . ok ) {
2131- throw new Error ( 'GitHub API request failed' ) ;
2132- }
2133- return response . json ( ) ;
2134- } )
2135- . then ( data => {
2136- if ( data . assets && data . assets . length > 0 ) {
2137- const asset = data . assets [ 0 ] ;
2138- const downloadUrl = asset . browser_download_url ;
2139-
2140- const downloadLink = document . createElement ( 'a' ) ;
2141- downloadLink . href = downloadUrl ;
2142- downloadLink . download = asset . name ;
2143- downloadLink . style . display = 'none' ;
2144- document . body . appendChild ( downloadLink ) ;
2145- downloadLink . click ( ) ;
2146- document . body . removeChild ( downloadLink ) ;
2147-
2148- downloadButton . innerHTML = `<span class="icon-download"></span> Download IDE (V: ${ data . tag_name } )` ;
2149- } else {
2150- throw new Error ( 'No download assets found' ) ;
2151- }
2152- } )
2153- . catch ( error => {
2154- console . error ( 'Download error:' , error ) ;
2155- window . open ( `${ repoUrl } /releases/latest` , '_blank' ) ;
2156- downloadButton . innerHTML = originalText ;
2157- } )
2158- . finally ( ( ) => {
2159- downloadButton . disabled = false ;
2160- } ) ;
2136+ window . location . href = downloadUrl ;
2137+ console . log ( 'Switching page:' , downloadUrl ) ;
21612138 } ) ;
2139+ } else {
2140+ console . error ( 'Download button not found' ) ;
21622141 }
21632142
2164- const githubButton = document . querySelector ( '.header-button:last-of-type' ) ;
2165- if ( githubButton ) {
2166- githubButton . addEventListener ( 'click' , function ( ) {
2167- window . open ( repoUrl , '_blank' ) ;
2143+ if ( downloadButton ) {
2144+ downloadButton . addEventListener ( 'click' , function ( ) {
2145+ const downloadLink = document . createElement ( 'a' ) ;
2146+ downloadLink . href = downloadUrl ;
2147+
2148+ document . body . appendChild ( downloadLink ) ;
2149+ downloadLink . click ( ) ;
2150+ document . body . removeChild ( downloadLink ) ;
2151+ console . log ( 'Switching to:' , downloadUrl ) ;
21682152 } ) ;
2153+ } else {
2154+ console . error ( 'Download button not found' ) ;
21692155 }
21702156 } ) ;
2171- </ script >
2157+ </ script >
21722158</ body >
21732159</ html>
0 commit comments