From 6f5101265679f0753168da9487520b6479fa6fd1 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 17 Jul 2022 19:39:23 +0300 Subject: badwolf: Added the switch -g which allows separated permanent storage between tabs --- badwolf.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'badwolf.c') diff --git a/badwolf.c b/badwolf.c index 5309a73..02e9dcf 100644 --- a/badwolf.c +++ b/badwolf.c @@ -32,6 +32,7 @@ static gboolean tray_enabled = false; static gboolean alt_useragent = false; static int custom_favicon_size = 30; static gboolean persistent_storage = false; +static gboolean separated_storage = false; static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data); static gboolean WebViewCb_web_process_terminated(WebKitWebView *webView, @@ -750,9 +751,17 @@ new_browser(struct Window *window, const gchar *target_url, struct Client *old_b webkit_web_context_set_web_extensions_directory(web_context, web_extensions_directory); webkit_web_context_set_favicon_database_directory(web_context, NULL); if (persistent_storage) { + char context_id_str[BADWOLF_CTX_SIZ] = {0, 0, 0, 0, 0, 0, 0}; + if (separated_storage) { + fmt_context_id(browser->context_id, context_id_str); + g_mkdir_with_parents( + g_build_filename(g_get_user_config_dir(), "badwolf", context_id_str, NULL), + 0755); + } + webkit_cookie_manager_set_persistent_storage( webkit_website_data_manager_get_cookie_manager(website_data_manager), - g_build_filename(g_get_user_config_dir(), "badwolf", "cookies.txt", NULL), + g_build_filename(g_get_user_config_dir(), "badwolf", context_id_str, "cookies.txt", NULL), WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT); webkit_cookie_manager_set_accept_policy( webkit_website_data_manager_get_cookie_manager(website_data_manager), @@ -1246,6 +1255,8 @@ main(int argc, char *argv[]) alt_useragent = TRUE; else if (argv[1][1] == 'p') persistent_storage = TRUE; + else if (argv[1][1] == 'g') + separated_storage = TRUE; else if (argv[1][1] == 's') { argv++; argc--; -- cgit v1.3.1-23-gd82d