2 * (C) Copyright 2007-2011,2013 John J. Foerch
3 * (C) Copyright 2007-2008 Jeremy Maitin-Shepard
5 * Use, modification, and distribution are subject to the terms specified in the
9 default_pref("general.useragent.extra.conkeror", "Conkeror/"+version);
12 * set_user_agent overrides the user agent string globally with whatever
13 * string is passed to it. If called with null or no argument, any
14 * current override is undone, reverting to Conkeror's default user agent
15 * string. The override is performed (rather non-conventionally) with a
16 * default pref instead of a user pref, which allows the override to be
17 * done cleanly from the rc, without interference by persisting prefs in
20 function set_user_agent (str) {
21 const p = "general.useragent.override";
23 clear_default_pref(p);
32 * user_agent_firefox returns a Firefox-like user agent string. It is
33 * alas, not perfect in all configurations, but should suffice for most
34 * ua-spoofing purposes.
36 function user_agent_firefox () {
37 var appinfo = Cc['@mozilla.org/xre/app-info;1']
38 .getService(Ci.nsIXULAppInfo);
39 var platform = { Darwin: "Macintosh",
43 }[get_os()] || get_os();
44 var geckoversion = appinfo.platformVersion;
45 var dot = geckoversion.indexOf(".");
46 var ldot = geckoversion.indexOf(".", dot + 1);
48 geckoversion = geckoversion.substring(0, ldot);
49 var geckotrail = appinfo.platformBuildID.substr(0, 8);
50 var firefoxversion = geckoversion;
51 return "Mozilla/5.0 "+
52 "("+platform+"; rv:"+geckoversion+") "+
53 "Gecko/"+geckotrail+" Firefox/"+firefoxversion;