Skip to content

Commit 599e2cf

Browse files
committed
Add support for Brave & Opera
1 parent 46b1e6e commit 599e2cf

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

src/interceptors/chromium-based-interceptors.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ abstract class ChromiumBasedInterceptor implements Interceptor {
3535
}
3636

3737
async isActivable() {
38-
return !!(await getBrowserDetails(this.config, this.variantName));
38+
const browserDetails = await getBrowserDetails(this.config, this.variantName)
39+
return !!browserDetails;
3940
}
4041

4142
async activate(proxyPort: number) {
@@ -76,6 +77,9 @@ abstract class ChromiumBasedInterceptor implements Interceptor {
7677
browser.process.once('close', () => {
7778
delete this.activeBrowsers[proxyPort];
7879

80+
// Opera has a launch proc that exits immediately in Windows, so we can't clear the profile there.
81+
if (process.platform === 'win32' && this.variantName === 'opera') return;
82+
7983
if (Object.keys(this.activeBrowsers).length === 0 && browserDetails && _.isString(browserDetails.profile)) {
8084
// If we were the last browser, and we have a profile path, and it's in our config
8185
// (just in case something's gone wrong) -> delete the profile to reset everything.
@@ -208,4 +212,26 @@ export class FreshEdgeCanary extends ChromiumBasedInterceptor {
208212
super(config, 'msedge-canary');
209213
}
210214

215+
};
216+
217+
export class FreshBrave extends ChromiumBasedInterceptor {
218+
219+
id = 'fresh-brave';
220+
version = '1.0.0';
221+
222+
constructor(config: HtkConfig) {
223+
super(config, 'brave');
224+
}
225+
226+
};
227+
228+
export class FreshOpera extends ChromiumBasedInterceptor {
229+
230+
id = 'fresh-opera';
231+
version = '1.0.0';
232+
233+
constructor(config: HtkConfig) {
234+
super(config, 'opera');
235+
}
236+
211237
};

src/interceptors/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import {
1212
FreshChromiumDev,
1313
FreshEdge,
1414
FreshEdgeBeta,
15-
FreshEdgeCanary
15+
FreshEdgeCanary,
16+
FreshBrave,
17+
FreshOpera
1618
} from './chromium-based-interceptors';
1719
import { FreshTerminalInterceptor } from './terminal/fresh-terminal-interceptor';
1820
import { ExistingTerminalInterceptor } from './terminal/existing-terminal-interceptor';
@@ -40,15 +42,23 @@ export function buildInterceptors(config: HtkConfig): _.Dictionary<Interceptor>
4042
new FreshChromeBeta(config),
4143
new FreshChromeDev(config),
4244
new FreshChromeCanary(config),
45+
4346
new FreshChromium(config),
4447
new FreshChromiumDev(config),
48+
4549
new FreshEdge(config),
4650
new FreshEdgeBeta(config),
4751
new FreshEdgeCanary(config),
52+
53+
new FreshOpera(config),
54+
new FreshBrave(config),
4855
new FreshFirefox(config),
56+
4957
new FreshTerminalInterceptor(config),
5058
new ExistingTerminalInterceptor(config),
59+
5160
new ElectronInterceptor(config),
61+
5262
new AndroidAdbInterceptor(config)
5363
];
5464

test/integration-test.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ describe('Integration test', function () {
158158
inactivable('fresh-edge'),
159159
inactivable('fresh-edge-beta'),
160160
inactivable('fresh-edge-canary'),
161+
inactivable('fresh-opera'),
162+
inactivable('fresh-brave'),
161163
activable('fresh-firefox'),
162164
activable('fresh-terminal'),
163165
activable('existing-terminal'),

0 commit comments

Comments
 (0)