|
107 | 107 | fetch(`https://api.github.com/repos/${owner}/${repo}/releases/latest`) |
108 | 108 | .then(res => res.json()) |
109 | 109 | .then(data => { |
110 | | - // Cherche le fichier MagicaSetup.exe |
111 | | - const exeAsset = data.assets.find(a => a.name === "MagicaSetup.exe"); |
112 | | - if (exeAsset) { |
113 | | - btn.textContent = "Télécharger la dernière version 📦"; |
114 | | - btn.onclick = () => window.location.href = exeAsset.browser_download_url; |
| 110 | + console.log("Tous les fichiers disponibles:", data.assets); |
| 111 | + |
| 112 | + // Cherche uniquement les fichiers .exe et exclut les .zip |
| 113 | + const exeAssets = data.assets.filter(a => |
| 114 | + a.name.toLowerCase().endsWith('.exe') && |
| 115 | + !a.name.toLowerCase().endsWith('.zip') |
| 116 | + ); |
| 117 | + |
| 118 | + console.log("Fichiers .exe trouvés:", exeAssets); |
| 119 | + |
| 120 | + if (exeAssets.length > 0) { |
| 121 | + // Prend le premier fichier .exe trouvé |
| 122 | + const exeAsset = exeAssets[0]; |
| 123 | + btn.textContent = `Télécharger ${exeAsset.name} 📦`; |
| 124 | + btn.onclick = () => { |
| 125 | + console.log("Téléchargement:", exeAsset.browser_download_url); |
| 126 | + window.location.href = exeAsset.browser_download_url; |
| 127 | + }; |
115 | 128 | } else { |
116 | | - btn.textContent = "Pas de MagicaSetup.exe trouvé dans la dernière version"; |
| 129 | + btn.textContent = "Aucun fichier .exe trouvé dans la dernière version"; |
117 | 130 | btn.disabled = true; |
| 131 | + console.log("Aucun .exe trouvé, voici les assets:", data.assets.map(a => a.name)); |
118 | 132 | } |
119 | 133 | }) |
120 | 134 | .catch(err => { |
121 | | - console.error(err); |
122 | | - btn.textContent = "Erreur API GitHub"; |
| 135 | + console.error("Erreur API GitHub:", err); |
| 136 | + btn.textContent = "Erreur de connexion à GitHub"; |
123 | 137 | btn.disabled = true; |
124 | 138 | }); |
125 | 139 | </script> |
|
0 commit comments