]> git.armaanb.net Git - chorizo.git/commitdiff
Steal surf's user agent
authorPeter Hofmann <scm@uninformativ.de>
Sat, 26 Jul 2014 08:17:15 +0000 (10:17 +0200)
committerPeter Hofmann <scm@uninformativ.de>
Sat, 26 Jul 2014 08:17:15 +0000 (10:17 +0200)
Ugly hackaround. Closes #6, though.

README
browser.c

diff --git a/README b/README
index 994c03f7e145a13cbd1b0fa2383577d9738588ca..52b1020c3c733ef26da3618764636bec969c3bd2 100644 (file)
--- 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.
 
index e65e742df256a452d4df3d76397e1b8811b4d527..b95b9ff9e4db442f0668277e8c2353caeecbf60a 100644 (file)
--- 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);