1- var clicks = 0
1+ var clicks = 0 ;
22
33var defaultThemes = [
44 {
@@ -64,7 +64,11 @@ async function getFeatureLanguageData() {
6464 var language = chrome . i18n . getUILanguage ( ) ?. includes ( "-" )
6565 ? chrome . i18n . getUILanguage ( ) . split ( "-" ) [ 0 ]
6666 : chrome . i18n . getUILanguage ( ) ;
67- var response = await fetch ( "/extras/feature-locales/" + language + ".json" ) ;
67+ try {
68+ var response = await fetch ( "/extras/feature-locales/" + language + ".json" ) ;
69+ } catch ( err ) {
70+ return { } ;
71+ }
6872 if ( response . ok ) {
6973 return response . json ( ) ;
7074 } else {
@@ -459,21 +463,27 @@ document.querySelector(".searchbar").placeholder =
459463
460464function getWords ( text , search ) {
461465 if ( ! search ) return true ;
462- if ( ! search . includes ( " " ) ) return text . toLowerCase ( ) . includes ( search . toLowerCase ( ) ) ;
463- text = text . replaceAll ( "\n" , " " ) . replaceAll ( "Credits:" , "" ) . replaceAll ( "Updated" , "" ) . replaceAll ( "New" , "" ) . toLowerCase ( )
464- search = search . toLowerCase ( )
466+ if ( ! search . includes ( " " ) )
467+ return text . toLowerCase ( ) . includes ( search . toLowerCase ( ) ) ;
468+ text = text
469+ . replaceAll ( "\n" , " " )
470+ . replaceAll ( "Credits:" , "" )
471+ . replaceAll ( "Updated" , "" )
472+ . replaceAll ( "New" , "" )
473+ . toLowerCase ( ) ;
474+ search = search . toLowerCase ( ) ;
465475 while ( text . includes ( " " ) ) {
466- text = text . replaceAll ( " " , " " )
476+ text = text . replaceAll ( " " , " " ) ;
467477 }
468- var oneWords = text . includes ( " " ) ? text . split ( " " ) : [ text ]
469-
470- var twoWords = search . includes ( " " ) ? search . split ( " " ) : [ search ]
478+ var oneWords = text . includes ( " " ) ? text . split ( " " ) : [ text ] ;
471479
472- var matchWords = oneWords . filter ( ( el ) => twoWords . includes ( el ) ) . length
480+ var twoWords = search . includes ( " " ) ? search . split ( " " ) : [ search ] ;
473481
474- var matchedPercentage = matchWords / twoWords . length
482+ var matchWords = oneWords . filter ( ( el ) => twoWords . includes ( el ) ) . length ;
475483
476- return matchedPercentage > .5
484+ var matchedPercentage = matchWords / twoWords . length ;
485+
486+ return matchedPercentage > 0.5 ;
477487}
478488
479489document . querySelector ( ".searchbar" ) . addEventListener ( "input" , function ( ) {
@@ -485,9 +495,7 @@ document.querySelector(".searchbar").addEventListener("input", function () {
485495 }
486496 }
487497 document . querySelectorAll ( ".feature" ) . forEach ( function ( el ) {
488- if (
489- getWords ( el . innerText , document . querySelector ( ".searchbar" ) . value )
490- ) {
498+ if ( getWords ( el . innerText , document . querySelector ( ".searchbar" ) . value ) ) {
491499 el . style . display = null ;
492500 } else {
493501 el . style . display = "none" ;
@@ -602,7 +610,7 @@ async function getFeatures() {
602610 input . checked = true ;
603611 }
604612 if ( feature . type . includes ( "Egg" ) && ! settings . includes ( feature . id ) ) {
605- div . classList . add ( "ste-easter-egg" )
613+ div . classList . add ( "ste-easter-egg" ) ;
606614 }
607615
608616 input . addEventListener ( "input" , async function ( ) {
@@ -628,7 +636,7 @@ async function getFeatures() {
628636 var ok = true ;
629637 }
630638 if ( ok ) {
631- this . parentNode . parentNode . style . display = null
639+ this . parentNode . parentNode . style . display = null ;
632640 this . checked = true ;
633641 await chrome . storage . sync . set ( {
634642 features : data + "." + this . parentNode . parentNode . dataset . id ,
@@ -726,9 +734,9 @@ async function getFeatures() {
726734 world : "MAIN" ,
727735 } ) ;
728736 function updateSettingsFunction ( feature , name , value ) {
729- ScratchTools . Storage [ name ] = value
737+ ScratchTools . Storage [ name ] = value ;
730738 if ( allSettingChangeFunctions [ feature ] ) {
731- allSettingChangeFunctions [ feature ] ( { key : name , value} ) ;
739+ allSettingChangeFunctions [ feature ] ( { key : name , value } ) ;
732740 }
733741 }
734742 } catch ( err ) {
@@ -1013,15 +1021,15 @@ document.getElementById("campsite")?.addEventListener("click", function () {
10131021} ) ;
10141022
10151023if ( document . querySelector ( ".main-page" ) ) {
1016- var logo = document . querySelector ( "div.sticon" )
1017- logo . addEventListener ( "click" , function ( ) {
1018- clicks += 1
1024+ var logo = document . querySelector ( "div.sticon" ) ;
1025+ logo . addEventListener ( "click" , function ( ) {
1026+ clicks += 1 ;
10191027 if ( clicks > 4 ) {
1020- clicks = 0
1021- document . querySelector ( ".buttons .selected" ) . classList . remove ( "selected" )
1028+ clicks = 0 ;
1029+ document . querySelector ( ".buttons .selected" ) . classList . remove ( "selected" ) ;
10221030 document . body . dataset . filter = "Egg" ;
10231031 }
1024- } )
1032+ } ) ;
10251033}
10261034
10271035if ( document . querySelector ( ".buttons" ) ) {
0 commit comments