tAdapt user agent handling - surf - customized build of surf, the suckless webk… | |
git clone git://src.adamsgaard.dk/surf | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 5bca2223399bb18bada2a48db7411d181e3186e6 | |
parent e6cefa584e605b8a9984b1a542098df1191adcb1 | |
Author: Quentin Rameau <[email protected]> | |
Date: Fri, 20 Nov 2015 17:12:00 +0100 | |
Adapt user agent handling | |
Now we can only append Surf version to the default WebKit user agent | |
instead of setting the whole string (while this remains possible to do). | |
Diffstat: | |
M config.def.h | 5 ++--- | |
M surf.c | 13 +++++++++---- | |
2 files changed, 11 insertions(+), 7 deletions(-) | |
--- | |
diff --git a/config.def.h b/config.def.h | |
t@@ -1,7 +1,6 @@ | |
/* modifier 0 means no modifier */ | |
-static char *useragent = "Mozilla/5.0 (X11; U; Unix; en-US) " | |
- "AppleWebKit/537.15 (KHTML, like Gecko) " | |
- "Chrome/24.0.1295.0 Safari/537.15 Surf/"VERSION; | |
+static int surfuseragent = 1; /* Append Surf version to default WebKit use… | |
+static char *fulluseragent = ""; /* Or override the whole user agent string */ | |
static char *scriptfile = "~/.surf/script.js"; | |
static char *styledir = "~/.surf/styles/"; | |
static char *cachedir = "~/.surf/cache/"; | |
diff --git a/surf.c b/surf.c | |
t@@ -112,6 +112,7 @@ static char pagestats[2]; | |
static GTlsDatabase *tlsdb; | |
static int cookiepolicy; | |
static char *stylefile = NULL; | |
+static const char *useragent; | |
static void addaccelgroup(Client *c); | |
static char *buildfile(const char *path); | |
t@@ -899,7 +900,6 @@ newview(Client *c, WebKitWebView *rv) | |
WebKitSettings *settings; | |
WebKitUserContentManager *contentmanager; | |
WebKitWebContext *context; | |
- char *ua; | |
/* Webview */ | |
if (rv) { | |
t@@ -918,12 +918,17 @@ newview(Client *c, WebKitWebView *rv) | |
"enable-javascript", enablescripts, | |
"enable-plugins", enableplugins, | |
NULL); | |
- if (!(ua = getenv("SURF_USERAGENT"))) | |
- ua = useragent; | |
- webkit_settings_set_user_agent(settings, ua); | |
/* Have a look at http://webkitgtk.org/reference/webkit2gtk/st… | |
* for more interesting settings */ | |
+ if (strcmp(fulluseragent, "")) { | |
+ webkit_settings_set_user_agent(settings, fulluseragent… | |
+ } else if (surfuseragent) { | |
+ webkit_settings_set_user_agent_with_application_detail… | |
+ settings, "Surf", VERSION); | |
+ } | |
+ useragent = webkit_settings_get_user_agent(settings); | |
+ | |
contentmanager = webkit_user_content_manager_new(); | |
context = webkit_web_context_new_with_website_data_manager( |