Skip to content

Commit

Permalink
Auto Adding google.crx to ChromeExtensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Antec authored and Antec committed Mar 29, 2024
1 parent c186230 commit e0e9188
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
1 change: 0 additions & 1 deletion OpenBullet2/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public void ConfigureServices(IServiceCollection services)
services.AddScoped<IWordlistRepository>(service =>
new HybridWordlistRepository(service.GetService<ApplicationDbContext>(),
"UserData/Wordlists"));

// Singletons
services.AddSingleton<UpdateService>();
services.AddSingleton<AnnouncementService>();
Expand Down
29 changes: 29 additions & 0 deletions RuriLib/Services/RuriLibSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ public class RuriLibSettingsService
private string EnvFile => Path.Combine(BaseFolder, "Environment.ini");
private string RlSettFile => Path.Combine(BaseFolder, "RuriLibSettings.json");

private string ChromeExtensionFile => Path.Combine(BaseFolder, "google.crx");

public EnvironmentSettings Environment { get; set; }
public GlobalSettings RuriLibSettings { get; set; }

public RuriLibSettingsService(string baseFolder)
{
BaseFolder = baseFolder;


Directory.CreateDirectory(baseFolder);

jsonSettings = new JsonSerializerSettings
Expand All @@ -40,8 +43,34 @@ public RuriLibSettingsService(string baseFolder)
RuriLibSettings = File.Exists(RlSettFile)
? JsonConvert.DeserializeObject<GlobalSettings>(File.ReadAllText(RlSettFile), jsonSettings)
: CreateGlobalSettings();

AddChromeExtensionIfExist();
}
public Task AddChromeExtensionIfExist()
{
// Check if the google.crx file exists
if (File.Exists(ChromeExtensionFile))
{
// Path to the ChromeExtensions directory
var chromeExtensionsDir = Path.Combine(BaseFolder, "ChromeExtensions");

// Ensure the ChromeExtensions directory exists
Directory.CreateDirectory(chromeExtensionsDir);

// Path to the destination file
var destinationFile = Path.Combine(chromeExtensionsDir, "google.crx");

// Copy the google.crx file to the ChromeExtensions directory
if (!File.Exists(destinationFile))
{
File.Copy(ChromeExtensionFile, destinationFile);
}
}
// Since there's no async work done here anymore, we can return a completed task
return Task.CompletedTask;
}


/// <summary>
/// Saves the settings to the designated file.
/// </summary>
Expand Down

0 comments on commit e0e9188

Please sign in to comment.