From b3c87eae580dbd2d5437b985850a363796f372ef Mon Sep 17 00:00:00 2001 From: Peter Hofmann Date: Sat, 26 Jul 2014 10:17:15 +0200 Subject: Steal surf's user agent Ugly hackaround. Closes #6, though. --- README | 4 ++++ browser.c | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/README b/README index 994c03f..52b1020 100644 --- a/README +++ b/README @@ -230,6 +230,10 @@ following environment variables: ("homepage" or "new window") and if no URIs are specified on the command line. Defaults to "about:blank". + LARIZA_USER_AGENT + Lariza will identify itself with this string. See source code + for the default value. + LARIZA_ZOOM Zoom level for WebKit viewports. Defaults to 1.0. diff --git a/browser.c b/browser.c index e65e742..b95b9ff 100644 --- a/browser.c +++ b/browser.c @@ -83,6 +83,10 @@ static gboolean language_is_set = FALSE; static gchar *search_text = NULL; static gboolean show_all_requests = FALSE; static gboolean tabbed_automagic = TRUE; +static gchar *user_agent = "Mozilla/5.0 (X11; U; Unix; en-US) " + "AppleWebKit/537.15 (KHTML, like Gecko) " + "Chrome/24.0.1295.0 " + "Safari/537.15 "__NAME_UPPERCASE__"/git"; void @@ -263,6 +267,9 @@ client_new(const gchar *uri) language_is_set = TRUE; } + g_object_set(G_OBJECT(webkit_web_view_get_settings(WEBKIT_WEB_VIEW(c->web_view))), + "user-agent", user_agent, NULL); + c->scroll = gtk_scrolled_window_new(NULL, NULL); gtk_container_add(GTK_CONTAINER(c->scroll), c->web_view); @@ -569,6 +576,10 @@ grab_environment_configuration(void) if (e != NULL) home_uri = g_strdup(e); + e = g_getenv(__NAME_UPPERCASE__"_USER_AGENT"); + if (e != NULL) + user_agent = g_strdup(e); + e = g_getenv(__NAME_UPPERCASE__"_ZOOM"); if (e != NULL) global_zoom = atof(e); -- cgit v1.2.3