webui-dev / webui

Use any web browser or WebView as GUI, with your preferred language in the backend and modern web technologies in the frontend, all in a lightweight portable library.
https://webui.me
MIT License
2.9k stars 164 forks source link

support browser extensions / using default profile #208

Closed 7flash closed 11 months ago

7flash commented 11 months ago

My app frontend app requires to invoke user wallet which is installed as a separate browser extension

Unfortunately, when running Chrome window with webui, it seems to create a new user profile with no extensions installed

How can I change the code to use existing user profile with existing extensions?

AlbertShown commented 11 months ago

You can modify the code quickly and remove the command line argument that uses the webui profile: https://github.com/webui-dev/webui/blob/2f22d6c280332632532a07191cd49a80a6abc842/src/webui.c#L3474C11-L3474C11

AlbertShown commented 11 months ago

Change:

c = sprintf(buffer, " --user-data-dir=\"%s\"", win->profile_path);

To:

c = sprintf(buffer, " ");

This will effect all Chromium-based bowsers.

AlbertShown commented 11 months ago

For Firefox:

https://github.com/webui-dev/webui/blob/2f22d6c280332632532a07191cd49a80a6abc842/src/webui.c#L3496

Change:

c = sprintf(buffer, " -P WebUI -purgecaches");

To:

c = sprintf(buffer, " -purgecaches");

hassandraga commented 11 months ago

Thank you @7flash @AlbertShown for the report. I will implement a new API to make it easier.

webui_set_profile(profileName, profilePath)

hassandraga commented 11 months ago

Implemented https://github.com/webui-dev/webui/commit/a616991ca679f0646bf35d580443e101369273ce.

To set your custom profile:

webui_set_profile(
    myWindow, 
    "Bar", // Your profile name, usually needed for Firefox
    "/Home/Foo/Bar" // Your profile folder, usually needed for Chrome
);

To simply let WebUI use the user default profile:

webui_set_profile(myWindow, "", "");
7flash commented 11 months ago

added in deno https://github.com/webui-dev/deno-webui/pull/14