@@ -15,6 +15,16 @@ const readFile = promisify(fs.readFile);
1515
1616let browsers : _ . Dictionary < BrowserInstance > = { } ;
1717
18+ // Should we launch Chrome, or Chromium, or do we have nothing available at all?
19+ const getChromeBrowserName = async ( config : HtkConfig ) : Promise < string | undefined > => {
20+ const browsers = await getAvailableBrowsers ( config . configPath ) ;
21+
22+ return _ ( browsers )
23+ . map ( b => b . name )
24+ . intersection ( [ 'chrome' , 'chromium' ] )
25+ . value ( ) [ 0 ] ;
26+ } ;
27+
1828export class FreshChrome {
1929 id = 'fresh-chrome' ;
2030 version = '1.0.0' ;
@@ -26,12 +36,7 @@ export class FreshChrome {
2636 }
2737
2838 async isActivable ( ) {
29- const browsers = await getAvailableBrowsers ( this . config . configPath ) ;
30-
31- return _ ( browsers )
32- . map ( b => b . name )
33- . includes ( 'chrome' )
34-
39+ return ! ! ( await getChromeBrowserName ( this . config ) ) ;
3540 }
3641
3742 async activate ( proxyPort : number ) {
@@ -44,7 +49,9 @@ export class FreshChrome {
4449 await hideWarningServer . start ( 'https://amiusing.httptoolkit.tech' ) ;
4550
4651 const browser = await launchBrowser ( hideWarningServer . hideWarningUrl , {
47- browser : 'chrome' ,
52+ // Try to launch Chrome if we're not sure - it'll trigger a config update,
53+ // and might find a new install.
54+ browser : ( await getChromeBrowserName ( this . config ) ) || 'chrome' ,
4855 proxy : `https://localhost:${ proxyPort } ` ,
4956 // Don't intercept our warning hiding requests
5057 noProxy : hideWarningServer . host ,
0 commit comments