@@ -277,9 +277,17 @@ document.addEventListener('DOMContentLoaded', () => {
277277 // Check for Live2D model file using the refined regex
278278 if ( item . type === 'file' && MODEL_FILE_REGEX . test ( item . name ) ) {
279279 const importBtn = document . createElement ( 'button' ) ;
280- importBtn . textContent = 'Import Model' ;
281280 importBtn . className = 'fe-import-model-btn' ;
282281 importBtn . title = `Import ${ item . name } to Live2D Viewer` ;
282+
283+ const importIcon = document . createElement ( 'i' ) ;
284+ importIcon . className = 'fas fa-file-import' ;
285+ importIcon . setAttribute ( 'aria-hidden' , 'true' ) ;
286+ importIcon . style . marginRight = '0.4em' ; // Add some space between icon and text
287+
288+ importBtn . appendChild ( importIcon ) ; // Icon first
289+ importBtn . appendChild ( document . createTextNode ( 'Import Model' ) ) ; // Then text
290+
283291 importBtn . addEventListener ( 'click' , ( e ) => {
284292 e . stopPropagation ( ) ; // Prevent li click event
285293 handleImportModel ( item ) ;
@@ -372,7 +380,7 @@ document.addEventListener('DOMContentLoaded', () => {
372380 showLoaderFE ( true ) ;
373381
374382 const jsDelivrUrl = `${ JSDELIVR_CDN_BASE } /${ currentOwner } /${ currentRepo } ${ DEFAULT_BRANCHE } /${ fileItem . path } ` ;
375- const rawGitHubUrl = fileItem . open_url ; // open_url is usually the raw content URL
383+ const rawGitHubUrl = fileItem . download_url ; // download_url is usually the raw content URL (GitHub API preference)
376384
377385 try {
378386 const extension = fileItem . name . split ( '.' ) . pop ( ) . toLowerCase ( ) ;
@@ -419,16 +427,24 @@ document.addEventListener('DOMContentLoaded', () => {
419427 // Add "Import Model" button to preview if applicable
420428 if ( fileItem . type === 'file' && MODEL_FILE_REGEX . test ( fileItem . name ) ) {
421429 const importBtnPreview = document . createElement ( 'button' ) ;
422- importBtnPreview . textContent = 'Import Model' ;
423430 importBtnPreview . className = 'fe-import-model-btn-preview' ;
424431 importBtnPreview . title = `Import ${ fileItem . name } to Live2D Viewer` ;
432+
433+ const importIconPreview = document . createElement ( 'i' ) ;
434+ importIconPreview . className = 'fas fa-file-import' ;
435+ importIconPreview . setAttribute ( 'aria-hidden' , 'true' ) ;
436+ importIconPreview . style . marginRight = '0.4em' ;
437+
438+ importBtnPreview . appendChild ( importIconPreview ) ;
439+ importBtnPreview . appendChild ( document . createTextNode ( 'Import Model' ) ) ;
440+
425441 importBtnPreview . addEventListener ( 'click' , ( ) => {
426442 handleImportModel ( fileItem , fileSourceUrl ) ; // Pass the successful source URL
427443 } ) ;
428444 previewActions . appendChild ( importBtnPreview ) ;
429445 }
430446
431- } catch ( error ) { // Didn't happen yet, not really tested
447+ } catch ( error ) {
432448 console . error ( 'File preview error:' , error ) ;
433449 previewContent . innerHTML = `<p class="fe-placeholder-text fe-error-message">Error loading preview: ${ error . message } </p>` ;
434450 // Add a link to view on GitHub as a last resort for any error
@@ -547,9 +563,9 @@ document.addEventListener('DOMContentLoaded', () => {
547563 * @param {string|null } [sourceUrlOverride=null] - Optional override for the model URL.
548564 */
549565 function handleImportModel ( fileItem , sourceUrlOverride = null ) {
550- // Prefer open_url if available and no override, as it's the direct raw content link.
551- // Fallback to jsDelivr if open_url is not present (should be rare for files).
552- const modelUrl = sourceUrlOverride || fileItem . open_url || `${ JSDELIVR_CDN_BASE } /${ currentOwner } /${ currentRepo } ${ DEFAULT_BRANCHE } /${ fileItem . path } ` ;
566+ // Prefer download_url if available and no override, as it's the direct raw content link.
567+ // Fallback to jsDelivr if download_url is not present (should be rare for files).
568+ const modelUrl = sourceUrlOverride || fileItem . download_url || `${ JSDELIVR_CDN_BASE } /${ currentOwner } /${ currentRepo } ${ DEFAULT_BRANCHE } /${ fileItem . path } ` ;
553569 console . log ( `Attempting to import Live2D Model: ${ modelUrl } ` ) ;
554570
555571 if ( window . loadLive2DModel && typeof window . loadLive2DModel === 'function' ) {
0 commit comments