@@ -166,12 +166,12 @@ function redirectToMainDomain() {
166
166
const target = mainDomainUrl + window . location . pathname ;
167
167
if ( window !== top ) {
168
168
try {
169
- top . location . href = target
169
+ top . location . href = target ;
170
170
} catch {
171
171
try {
172
- parent . location . href = target
172
+ parent . location . href = target ;
173
173
} catch {
174
- window . location . href = target
174
+ window . location . href = target ;
175
175
}
176
176
}
177
177
} else window . location . href = mainDomainUrl + window . location . pathname ;
@@ -375,17 +375,17 @@ function randRange(min, max) {
375
375
376
376
function exportSaveData ( ) {
377
377
function getCookies ( ) {
378
- let cookies = document . cookie . split ( '; ' ) ;
379
- let cookieObj = { } ;
378
+ const cookies = document . cookie . split ( "; " ) ;
379
+ const cookieObj = { } ;
380
380
cookies . forEach ( cookie => {
381
- let [ name , value ] = cookie . split ( '=' ) ;
381
+ const [ name , value ] = cookie . split ( "=" ) ;
382
382
cookieObj [ name ] = value ;
383
383
} ) ;
384
384
return cookieObj ;
385
385
}
386
386
function getLocalStorage ( ) {
387
- let localStorageObj = { } ;
388
- for ( let key in localStorage ) {
387
+ const localStorageObj = { } ;
388
+ for ( const key in localStorage ) {
389
389
if ( localStorage . hasOwnProperty ( key ) ) {
390
390
localStorageObj [ key ] = localStorage . getItem ( key ) ;
391
391
}
@@ -394,29 +394,29 @@ function exportSaveData() {
394
394
}
395
395
const data = {
396
396
cookies : getCookies ( ) ,
397
- localStorage : getLocalStorage ( )
397
+ localStorage : getLocalStorage ( ) ,
398
398
} ;
399
399
const dataStr = JSON . stringify ( data , null , 2 ) ;
400
- const blob = new Blob ( [ dataStr ] , { type : ' application/json' } ) ;
400
+ const blob = new Blob ( [ dataStr ] , { type : " application/json" } ) ;
401
401
const url = URL . createObjectURL ( blob ) ;
402
- const a = document . createElement ( 'a' ) ;
402
+ const a = document . createElement ( "a" ) ;
403
403
a . href = url ;
404
- a . download = ' save_data.json' ;
404
+ a . download = " save_data.json" ;
405
405
document . body . appendChild ( a ) ;
406
406
a . click ( ) ;
407
407
document . body . removeChild ( a ) ;
408
408
URL . revokeObjectURL ( url ) ;
409
409
}
410
410
411
411
function importSaveData ( ) {
412
- const input = document . createElement ( ' input' ) ;
413
- input . type = ' file' ;
414
- input . accept = ' application/json' ;
415
- input . onchange = function ( event ) {
412
+ const input = document . createElement ( " input" ) ;
413
+ input . type = " file" ;
414
+ input . accept = " application/json" ;
415
+ input . onchange = event => {
416
416
const file = event . target . files [ 0 ] ;
417
417
if ( ! file ) return ;
418
418
const reader = new FileReader ( ) ;
419
- reader . onload = function ( e ) {
419
+ reader . onload = e => {
420
420
try {
421
421
const data = JSON . parse ( e . target . result ) ;
422
422
if ( data . cookies ) {
@@ -429,14 +429,15 @@ function importSaveData() {
429
429
localStorage . setItem ( key , value ) ;
430
430
} ) ;
431
431
}
432
- alert ( 'Your save data has been imported. Please test it out.' )
433
- alert ( 'If you find any issues then report it in GitHub or the Interstellar Discord.' )
432
+ alert ( "Your save data has been imported. Please test it out." ) ;
433
+ alert (
434
+ "If you find any issues then report it in GitHub or the Interstellar Discord." ,
435
+ ) ;
434
436
} catch ( error ) {
435
- console . error ( ' Error parsing JSON file:' , error ) ;
437
+ console . error ( " Error parsing JSON file:" , error ) ;
436
438
}
437
439
} ;
438
440
reader . readAsText ( file ) ;
439
441
} ;
440
442
input . click ( ) ;
441
443
}
442
-
0 commit comments