fix: add mobile to user-agent (MR 35)

This commit is contained in:
Seth Falco 2023-09-01 15:58:24 +02:00
parent e1c533d84e
commit 9c780dabb8
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -263,8 +263,31 @@ function css_files_update() {
set_firefox_version_previous(g_ff_version);
}
/**
* Builds a user-agent as similar to the default as possible, but with "Mobile"
* inserted into the platforms section.
*
* @returns {string}
*/
function build_user_agent() {
var appinfo = Services.appinfo;
var vendor = appinfo.vendor || "Mozilla";
var os = appinfo.OS || "Linux";
var version = get_firefox_version() + ".0";
var name = appinfo.name || "Firefox";
var arch = (appinfo.XPCOMABI && appinfo.XPCOMABI.includes("-"))
? appinfo.XPCOMABI.split("-")[0]
: "aarch64";
return `${vendor}/5.0 (X11; ${os} ${arch}; Mobile; rv:${version}) Gecko/20100101 ${name}/${version}`;
}
function set_default_prefs() {
log("Setting default preferences");
var user_agent = build_user_agent();
defaultPref('general.useragent.override', user_agent);
// Do not suggest facebook, ebay, reddit etc. in the urlbar. Same as
// Settings -> Privacy & Security -> Address Bar -> Shortcuts. As
// side-effect, the urlbar results are not immediatelly opened once