[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r19062: {torbutton} Reset useragent spoofing on startup if Tor is enabled to fig (torbutton/trunk/src/chrome/content)
Author: mikeperry
Date: 2009-03-16 22:01:43 -0400 (Mon, 16 Mar 2009)
New Revision: 19062
Modified:
torbutton/trunk/src/chrome/content/torbutton.js
Log:
Reset useragent spoofing on startup if Tor is enabled
to fight with UserAgentSwitcher.
Modified: torbutton/trunk/src/chrome/content/torbutton.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton.js 2009-03-17 01:40:56 UTC (rev 19061)
+++ torbutton/trunk/src/chrome/content/torbutton.js 2009-03-17 02:01:43 UTC (rev 19062)
@@ -61,6 +61,7 @@
{
register: function()
{
+ this.forced_ua = false;
var pref_service = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranchInternal);
this._branch = pref_service.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
@@ -845,6 +846,60 @@
}
}
+function torbutton_set_uagent() {
+ try {
+ var torprefs = torbutton_get_prefbranch('extensions.torbutton.');
+ var lang = new RegExp("LANG", "gm");
+ var appname = torprefs.getCharPref("appname_override");
+ var appvers = torprefs.getCharPref("appversion_override");
+ if(torprefs.getBoolPref("spoof_english")) {
+ appname = appname.replace(lang,
+ torprefs.getCharPref("spoof_locale"));
+ appvers = appvers.replace(lang,
+ torprefs.getCharPref("spoof_locale"));
+ } else {
+ appname = appname.replace(lang,
+ m_tb_prefs.getCharPref("general.useragent.locale"));
+ appvers = appvers.replace(lang,
+ m_tb_prefs.getCharPref("general.useragent.locale"));
+ }
+ m_tb_prefs.setCharPref("general.appname.override", appname);
+
+ m_tb_prefs.setCharPref("general.appversion.override", appvers);
+
+ m_tb_prefs.setCharPref("general.platform.override",
+ torprefs.getCharPref("platform_override"));
+
+ var agent = torprefs.getCharPref("useragent_override");
+ if(torprefs.getBoolPref("spoof_english")) {
+ agent = agent.replace(lang,
+ torprefs.getCharPref("spoof_locale"));
+ } else {
+ agent = agent.replace(lang,
+ m_tb_prefs.getCharPref("general.useragent.locale"));
+ }
+ m_tb_prefs.setCharPref("general.useragent.override", agent);
+
+ m_tb_prefs.setCharPref("general.useragent.vendor",
+ torprefs.getCharPref("useragent_vendor"));
+
+ m_tb_prefs.setCharPref("general.useragent.vendorSub",
+ torprefs.getCharPref("useragent_vendorSub"));
+
+ m_tb_prefs.setCharPref("general.oscpu.override",
+ torprefs.getCharPref("oscpu_override"));
+
+ m_tb_prefs.setCharPref("general.buildID.override",
+ torprefs.getCharPref("buildID_override"));
+
+ m_tb_prefs.setCharPref("general.productSub.override",
+ torprefs.getCharPref("productsub_override"));
+ } catch(e) {
+ torbutton_log(5, "Prefset error");
+ }
+}
+
+
// NOTE: If you touch any additional prefs in here, be sure to update
// the list in torbutton_util.js::torbutton_reset_browser_prefs()
function torbutton_update_status(mode, force_update) {
@@ -898,57 +953,7 @@
if(torprefs.getBoolPref("set_uagent")) {
if(mode) {
- try {
- var lang = new RegExp("LANG", "gm");
- var appname = torprefs.getCharPref("appname_override");
- var appvers = torprefs.getCharPref("appversion_override");
- if(torprefs.getBoolPref("spoof_english")) {
- appname = appname.replace(lang,
- torprefs.getCharPref("spoof_locale"));
- appvers = appvers.replace(lang,
- torprefs.getCharPref("spoof_locale"));
- } else {
- appname = appname.replace(lang,
- m_tb_prefs.getCharPref("general.useragent.locale"));
- appvers = appvers.replace(lang,
- m_tb_prefs.getCharPref("general.useragent.locale"));
- }
-
- m_tb_prefs.setCharPref("general.appname.override", appname);
-
- m_tb_prefs.setCharPref("general.appversion.override", appvers);
-
- m_tb_prefs.setCharPref("general.platform.override",
- torprefs.getCharPref("platform_override"));
-
- var agent = torprefs.getCharPref("useragent_override");
- if(torprefs.getBoolPref("spoof_english")) {
- agent = agent.replace(lang,
- torprefs.getCharPref("spoof_locale"));
- } else {
- agent = agent.replace(lang,
- m_tb_prefs.getCharPref("general.useragent.locale"));
- }
- m_tb_prefs.setCharPref("general.useragent.override", agent);
-
- m_tb_prefs.setCharPref("general.useragent.vendor",
- torprefs.getCharPref("useragent_vendor"));
-
- m_tb_prefs.setCharPref("general.useragent.vendorSub",
- torprefs.getCharPref("useragent_vendorSub"));
-
- m_tb_prefs.setCharPref("general.oscpu.override",
- torprefs.getCharPref("oscpu_override"));
-
- m_tb_prefs.setCharPref("general.buildID.override",
- torprefs.getCharPref("buildID_override"));
-
- m_tb_prefs.setCharPref("general.productSub.override",
- torprefs.getCharPref("productsub_override"));
-
- } catch(e) {
- torbutton_log(5, "Prefset error");
- }
+ torbutton_set_uagent();
} else {
try {
if(m_tb_prefs.prefHasUserValue("general.appname.override"))
@@ -2308,6 +2313,13 @@
torbutton_do_main_window_startup();
+ // This is due to Bug 908: UserAgent Switcher is resetting
+ // the user agent at startup to default
+ if(m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled")
+ && m_tb_prefs.getBoolPref("extensions.torbutton.set_uagent")) {
+ torbutton_set_uagent();
+ }
+
torbutton_set_timezone(torbutton_check_status(), true);
// XXX: This is probably better done by reimplementing the