Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge (Chromium) multiple profiles #61

Open
jonhil opened this issue Jan 14, 2020 · 5 comments
Open

Edge (Chromium) multiple profiles #61

jonhil opened this issue Jan 14, 2020 · 5 comments

Comments

@jonhil
Copy link

jonhil commented Jan 14, 2020

Hello,

BrowserSelect does not detect every profile in the new edge based on chromium.
The app does only show the Browser itself and not every profile as it does with chrome.

@jonhil jonhil changed the title Edge ( Chromium) multiple profiles Edge (Chromium) multiple profiles Jan 15, 2020
@miguel-ka
Copy link

Is Edge handling profiles differently than Chromium, even if it is based on it? Would be a great feature.

@JaspalX
Copy link
Contributor

JaspalX commented Jun 15, 2020

Is Edge handling profiles differently than Chromium, even if it is based on it? Would be a great feature.

edge chromium profiles seem to be working the same as google chrome profiles (as in folder structure etc.) ...if that's what you're asking?

@JaspalX
Copy link
Contributor

JaspalX commented Jun 20, 2020

fwiw, I hacked browser.cs to find edge chromium profiles...it seems to be unable to work out the name of the profile when you've got a logged in microsoft account, but it does work. I'm too unfamiliar with github and c# coding to work out how to get this into the main code base, but if anyone wants the code here it is (replaces from line 131 to 178 in the original browser.cs file):

                //check for edge chromium profiles
                AddChromeProfiles(browsers, "Microsoft Edge", @"Microsoft\Edge\User Data", "Edge Profile.ico");
                
                //Check for Chrome Profiles
                AddChromeProfiles(browsers, "Google Chrome", @"Google\Chrome\User Data", "Google Profile.ico");

                System.Diagnostics.Debug.WriteLine(JsonConvert.SerializeObject(browsers));
                Properties.Settings.Default.BrowserList = JsonConvert.SerializeObject(browsers);
                Properties.Settings.Default.Save();
            }

            return browsers;
        }

        private static void AddChromeProfiles(List<Browser> browsers, string BrowserName, string VendorDataFolder, string IconFilename)
        {
            Browser BrowserChrome = browsers.FirstOrDefault(x => x.name == BrowserName);
            if (BrowserChrome != null)
            {
                string ChromeUserDataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), VendorDataFolder);
                List<string> ChromeProfiles = FindChromeProfiles(ChromeUserDataDir, IconFilename);

                if (ChromeProfiles.Count > 1)
                {
                    //add the Chrome instances and remove the default one
                    foreach (string Profile in ChromeProfiles)
                    {
                        browsers.Add(new Browser()
                        {
                            name = BrowserName + " (" + GetChromeProfileName(ChromeUserDataDir + "\\" + Profile) + ")",
                            exec = BrowserChrome.exec,
                            icon = icon2String(IconExtractor.fromFile(ChromeUserDataDir + "\\" + Profile + "\\" + IconFilename)),
                            additionalArgs = String.Format("--profile-directory={0}", Profile)
                        });
                    }
                    browsers.Remove(BrowserChrome);
                    browsers = browsers.OrderBy(x => x.name).ToList();
                }
            }
        }
        private static string GetChromeProfileName(string FullProfilePath)
        {
            dynamic ProfilePreferences = JObject.Parse(File.ReadAllText(FullProfilePath + @"\Preferences"));
            return ProfilePreferences.profile.name;
        }
        
        private static List<string> FindChromeProfiles(string ChromeUserDataDir, string IconFilename)
        {
            List<string> Profiles = new List<string>();
            var ProfileDirs = Directory.GetFiles(ChromeUserDataDir, IconFilename, SearchOption.AllDirectories).Select(Path.GetDirectoryName);
            foreach (var Profile in ProfileDirs)
            {
                Profiles.Add(Profile.Substring(ChromeUserDataDir.Length + 1));
            }
            return Profiles;
        }

@zumoshi fyi

@JaspalX
Copy link
Contributor

JaspalX commented Jun 20, 2020

...now if someone could show me how to fix it so that I could launch different browsers for the same domain but different url pattern+wildcard rather than just one domain= one browser that would be awesome :)

@zumoshi
Copy link
Owner

zumoshi commented Jun 21, 2020

Thanks for looking into it. If you would create a pull request I will accept it and make an official release with your changes.

I'm too unfamiliar with github

There are some good resources on how to do that:
https://opensource.com/article/19/7/create-pull-request-github
https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request

same domain but different url

That is unrelated to this issue, please open a new one. But in short, the wildcard is already supported, (e.g. *.whatever.com), You just need to include the path in the string the rules are checked against. Somewhere around here. Check the Uri Class documentation for properties other than Host to check. The tricky part would be to make sure it won't break domain-only rules if say the domain name existed somewhere in the url's path. (e.g. something.com/link/somethingelse.com/ )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants