@@ -25,11 +25,8 @@ function getHighResImageUrl(src) {
2525function formatDate ( dateStr ) {
2626 const date = new Date ( dateStr ) ;
2727 if ( ! isNaN ( date ) ) {
28- if ( / ^ \d { 4 } $ / . test ( dateStr . trim ( ) ) ) return `01/01/${ dateStr . trim ( ) } ` ;
29- const mm = String ( date . getMonth ( ) + 1 ) . padStart ( 2 , '0' ) ;
30- const dd = String ( date . getDate ( ) ) . padStart ( 2 , '0' ) ;
31- const yyyy = date . getFullYear ( ) ;
32- return `${ mm } /${ dd } /${ yyyy } ` ;
28+ // navigator.language should always be set, but adding a fallback just in case
29+ return new Intl . DateTimeFormat ( navigator . language || "en-US" ) . format ( date ) ;
3330 }
3431 return dateStr ;
3532}
@@ -141,9 +138,9 @@ export function renderDetails(details) {
141138 img . alt = 'Cover Image' ;
142139 img . title = 'Click to download' ;
143140 img . style . maxWidth = '100px' ;
144- img . style . minHeight = '100px' ;
141+ img . style . minHeight = '100px' ;
145142 img . style . cursor = 'pointer' ;
146- img . loading = 'lazy' ; // lazy load for performance
143+ img . loading = 'lazy' ; // lazy load for performance
147144 img . addEventListener ( 'click' , ( ) => {
148145 const fallbackId =
149146 details [ 'ISBN-13' ] ||
@@ -251,9 +248,9 @@ export function renderDetails(details) {
251248 container . appendChild ( hr ) ;
252249
253250 const orderedKeys = [
254- 'ISBN-10' , 'ISBN-13' , 'ASIN' , 'Source ID' , 'Contributors' , 'Publisher' ,
255- 'Reading Format' , 'Listening Length' , 'Pages' , 'Edition Format' ,
256- 'Publication date' , 'Language'
251+ 'ISBN-10' , 'ISBN-13' , 'ASIN' , 'Source ID' , 'Contributors' , 'Publisher' ,
252+ 'Reading Format' , 'Listening Length' , 'Pages' , 'Edition Format' ,
253+ 'Publication date' , 'Language'
257254 ] ;
258255
259256 const rendered = new Set ( [ 'Series' , 'Series Place' ] ) ;
@@ -264,7 +261,7 @@ export function renderDetails(details) {
264261 }
265262 } ) ;
266263
267- const filteredKeys = [ 'img' , 'imgScore' , 'Title' , 'Description' ] ;
264+ const filteredKeys = [ 'img' , 'imgScore' , 'Title' , 'Description' ] ;
268265 Object . entries ( details ) . forEach ( ( [ key , value ] ) => {
269266 if ( filteredKeys . includes ( key ) || rendered . has ( key ) ) return ;
270267 renderRow ( container , key , value ) ;
@@ -282,7 +279,7 @@ export function showStatus(message) {
282279
283280export function showDetails ( ) {
284281 const detailsEl = detailsBox ( ) ;
285- if ( ! detailsEl ) return ;
282+ if ( ! detailsEl ) return ;
286283 detailsEl . style . display = 'block' ;
287284}
288285
@@ -310,7 +307,7 @@ export function initSidebarLogger() {
310307 host . scrollTop = host . scrollHeight ;
311308 } ;
312309
313- [ 'log' , 'warn' , 'error' , 'debug' ] . forEach ( fn => {
310+ [ 'log' , 'warn' , 'error' , 'debug' ] . forEach ( fn => {
314311 const original = console [ fn ] . bind ( console ) ;
315312 console [ fn ] = ( ...args ) => { append ( fn , args ) ; original ( ...args ) ; } ;
316313 } ) ;
@@ -326,7 +323,7 @@ export function addRefreshButton(onClick) {
326323 const btn = document . createElement ( 'button' ) ;
327324 btn . id = 'refresh-button' ;
328325 btn . textContent = 'Refresh details from current tab' ;
329- btn . style . display = 'none' ;
326+ btn . style . display = 'none' ;
330327
331328 btn . addEventListener ( 'click' , ( ) => {
332329 if ( btn . disabled ) return ; // bail if not allowed
@@ -387,4 +384,4 @@ export function checkActiveTabAndUpdateButton() {
387384 chrome . tabs . query ( { active : true , currentWindow : true } , ( [ tab ] ) => {
388385 updateRefreshButtonForUrl ( tab ?. url || "" ) ;
389386 } ) ;
390- }
387+ }
0 commit comments