@@ -71,19 +71,22 @@ new (class ExtensionPopup {
7171  restoreSettings ( )  { 
7272    if  ( logging )  console . log ( "restoreSettings called" ) ; 
7373    // Restore global settings 
74-     this . enableStylingSwitch . checked  =  this . globalSettings . enableStyling  ??  true ; 
74+     this . enableStylingSwitch . checked  = 
75+       this . globalSettings . enableStyling  ??  true ; 
7576    this . autoUpdateSwitch . checked  =  this . globalSettings . autoUpdate  ??  false ; 
7677    this . loadCurrentSiteFeatures ( ) ; 
7778  } 
7879
7980  async  loadSettings ( )  { 
8081    if  ( logging )  console . log ( "loadSettings called" ) ; 
8182    // Load global settings 
82-     const  globalData  =  await  browser . storage . local . get ( this . BROWSER_STORAGE_KEY ) ; 
83+     const  globalData  =  await  browser . storage . local . get ( 
84+       this . BROWSER_STORAGE_KEY 
85+     ) ; 
8386    this . globalSettings  =  globalData [ this . BROWSER_STORAGE_KEY ]  ||  { 
8487      enableStyling : true , 
8588      autoUpdate : false , 
86-       lastFetchedTime : null 
89+       lastFetchedTime : null , 
8790    } ; 
8891
8992    // Load site-specific settings if on a specific site 
@@ -101,18 +104,20 @@ new (class ExtensionPopup {
101104    this . globalSettings . enableStyling  =  this . enableStylingSwitch . checked ; 
102105    this . globalSettings . autoUpdate  =  this . autoUpdateSwitch . checked ; 
103106
104-     browser . storage . local . set ( { 
105-       [ this . BROWSER_STORAGE_KEY ] : this . globalSettings 
106-     } ) . then ( ( )  =>  { 
107-       if  ( logging )  console . log ( "Global settings saved" ) ; 
108-       this . updateActiveTabStyling ( ) ; 
109-     } ) ; 
107+     browser . storage . local 
108+       . set ( { 
109+         [ this . BROWSER_STORAGE_KEY ] : this . globalSettings , 
110+       } ) 
111+       . then ( ( )  =>  { 
112+         if  ( logging )  console . log ( "Global settings saved" ) ; 
113+         this . updateActiveTabStyling ( ) ; 
114+       } ) ; 
110115
111116    // Save site-specific settings 
112117    if  ( this . currentSiteHostname )  { 
113118      const  siteKey  =  `${ this . BROWSER_STORAGE_KEY } ${ this . currentSiteHostname }  ; 
114119      const  featureSettings  =  { } ; 
115-        
120+ 
116121      this . currentSiteFeatures 
117122        . querySelectorAll ( "input[type=checkbox]" ) 
118123        . forEach ( ( checkbox )  =>  { 
@@ -121,17 +126,19 @@ new (class ExtensionPopup {
121126        } ) ; 
122127
123128      this . siteSettings  =  featureSettings ; 
124-       browser . storage . local . set ( { 
125-         [ siteKey ] : featureSettings 
126-       } ) . then ( ( )  =>  { 
127-         if  ( logging )  console . log ( "Site settings saved" ) ; 
128-         this . updateActiveTabStyling ( ) ; 
129-       } ) ; 
129+       browser . storage . local 
130+         . set ( { 
131+           [ siteKey ] : featureSettings , 
132+         } ) 
133+         . then ( ( )  =>  { 
134+           if  ( logging )  console . log ( "Site settings saved" ) ; 
135+           this . updateActiveTabStyling ( ) ; 
136+         } ) ; 
130137    } 
131138
132139    console . info ( "Settings saved" ,  { 
133140      global : this . globalSettings , 
134-       site : this . siteSettings 
141+       site : this . siteSettings , 
135142    } ) ; 
136143  } 
137144
@@ -178,7 +185,9 @@ new (class ExtensionPopup {
178185        featureToggle . innerHTML  =  ` 
179186          <span class="feature-name">${ displayFeatureName }  
180187          <label class="toggle-switch"> 
181-             <input type="checkbox" name="${ currentSiteKey } ${ feature } ${ isChecked  ? "checked"  : "" }  
188+             <input type="checkbox" name="${ currentSiteKey } ${ feature } ${  
189+           isChecked  ? "checked"  : ""  
190+         }  >
182191            <span class="slider round"></span> 
183192          </label> 
184193        ` ; 
@@ -195,6 +204,10 @@ new (class ExtensionPopup {
195204  isCurrentSite ( siteName )  { 
196205    if  ( logging )  console . log ( "isCurrentSite called with" ,  siteName ) ; 
197206    if  ( ! this . currentSiteHostname )  return  false ; 
207+     if  ( siteName . startsWith ( "+" ) )  { 
208+       const  baseSiteName  =  siteName . slice ( 1 ) ; 
209+       return  this . currentSiteHostname . endsWith ( baseSiteName ) ; 
210+     } 
198211    if  ( this . currentSiteHostname  ===  siteName )  return  true ; 
199212    if  ( this . currentSiteHostname  ===  `www.${ siteName }  )  return  true ; 
200213    return  false ; 
@@ -267,7 +280,13 @@ new (class ExtensionPopup {
267280      let  siteKey  =  null ; 
268281      for  ( const  site  of  Object . keys ( styles ) )  { 
269282        const  siteName  =  site . replace ( / \. c s s $ / ,  "" ) ; 
270-         if  ( hostname  ===  siteName  ||  hostname  ===  `www.${ siteName }  )  { 
283+         if  ( siteName . startsWith ( "+" ) )  { 
284+           const  baseSiteName  =  siteName . slice ( 1 ) ; 
285+           if  ( hostname . endsWith ( baseSiteName ) )  { 
286+             siteKey  =  site ; 
287+             break ; 
288+           } 
289+         }  else  if  ( hostname  ===  siteName  ||  hostname  ===  `www.${ siteName }  )  { 
271290          siteKey  =  site ; 
272291          break ; 
273292        } 
0 commit comments