diff --git a/README.md b/README.md index 41524e6..b0090b9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Mobile-Friendly Firefox Customizations for Librem 5 (mirror) -Mobile and privacy friendly configuration for Firefox >= 91. +Mobile and privacy friendly configuration for current standard and extended +support releases of Firefox. This **read-only mirror** is tracking all changes posted by `@user0` in the thread [Mobile-Friendly Firefox Customizations for Librem 5](https://forums.puri.sm/t/20313) on Purism’s forums. @@ -22,7 +23,6 @@ repository also does not replace a proper implementation in * Adapt UI elements and "about:" pages to small screen sizes (when opened on small screen) * Enable mobile gestures -* User agent set to same as Tor Browser for Android * Privacy tweaks: * Disable search suggestions * Disable Firefox studies @@ -109,10 +109,10 @@ changes are applied. The `src/mobile-config-autoconfig.js` script generates `userChrome.css` and `userContent.css` while Firefox starts. It logs to your Firefox profile -directory, find the log file with: +directory, follow the log file with: ``` -$ find ~/.mozilla -name mobile-config-firefox.log +$ tail -F $(find ~/.mozilla -name mobile-config-firefox.log) ``` ## Coding guidelines diff --git a/src/mobile-config-autoconfig.js b/src/mobile-config-autoconfig.js index 5d9691d..5693847 100644 --- a/src/mobile-config-autoconfig.js +++ b/src/mobile-config-autoconfig.js @@ -18,7 +18,7 @@ // https://web.archive.org/web/20201018211550/https://developer.mozilla.org/en-US/docs/Archive/Add-ons/Code_snippets/File_I_O const {classes: Cc, interfaces: Ci, utils: Cu} = Components; -Cu.import("resource://gre/modules/Services.jsm"); +const Services = globalThis.Services || Cu.import("resource://gre/modules/Services.jsm").Services; // for compatibility with FF < 104 Cu.import("resource://gre/modules/FileUtils.jsm"); var g_ff_version; @@ -71,12 +71,7 @@ function log_obj(obj) { } function get_firefox_version() { - try { - return Services.appinfo.lastAppVersion.split(".")[0]; - } catch(e) { - log("Couldn't get Firefox version (expected on first start): " + e); - return 0; - } + return Services.appinfo.version.split(".")[0]; } function get_firefox_version_previous() { @@ -250,10 +245,7 @@ function css_files_update() { var file = css_file_get(name); if (file.exists()) { - /* During the very first start, ff_previous is first "unknown", - * then the files get installed and Firefox gets restarted. - * Then ff_previous is 0. Don't restart it again. */ - if (ff_previous != 0 && g_ff_version != ff_previous) { + if (g_ff_version != ff_previous) { log("Removing outdated file: " + file.path + " (Firefox" + " version changed)"); file.remove(false); @@ -271,10 +263,30 @@ 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"); - // Select a mobile user agent for firefox (same as tor browser on android) - defaultPref('general.useragent.override', 'Mozilla/5.0 (Android 10; Mobile; rv:110.0) Gecko/110.0 Firefox/110.0'); + + 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 @@ -297,6 +309,12 @@ function set_default_prefs() { // shows recently closed tabs. The always pinned tab takes up screen estate // and it's slightly annoying if you do not want to register an account. defaultPref('browser.tabs.firefox-view', false); + + // FF >= 116 allows to use cameras via Pipewire. While it will likely still + // take a while until this is made the default, on most mobile devices it + // makes a lot of sense to enable it unconditionally, as cameras usually + // only work with libcamera, not via plain v4l2. + defaultPref('media.webrtc.camera.allow-pipewire', true); } function main() { diff --git a/src/userChrome/browser.css b/src/userChrome/browser.css index e84c874..28cfcb2 100644 --- a/src/userChrome/browser.css +++ b/src/userChrome/browser.css @@ -1,10 +1,11 @@ /* Copyright 2022 plata * SPDX-License-Identifier: MPL-2.0 */ -/* Move navigation bar to bottom */ @media (max-width: 700px) { + /* Move navigation bar to bottom */ #browser { - -moz-box-ordinal-group: 0 !important; + -moz-box-ordinal-group: 0 !important; /* before FF 113 */ + order: -1 !important; /* since FF 113 */ } /* Hide navigation bar in kiosk mode (to prevent bug #29). We can assume FF diff --git a/src/userChrome/tabmenu.css b/src/userChrome/tabmenu.css index 298c334..c3ca01a 100644 --- a/src/userChrome/tabmenu.css +++ b/src/userChrome/tabmenu.css @@ -61,7 +61,8 @@ /*max-height: 300px !important; /* When messing around with tabs, it gets into a state where it does * not use the whole height anymore, it becomes a tiny window. Removing - * this attribute fixes it. */ + * this attribute fixes it. Since FF 113, this no longer has any + * effect, but it doesn't seem to be necessary either. */ /*-moz-box-flex: initial !important; }*/ @@ -72,13 +73,19 @@ /*overflow-y: hidden !important; }*/ - #allTabsMenu-multiView box.panel-viewstack { + #allTabsMenu-multiView box.panel-viewstack { /* before FF 102 or earlier */ /* Use the whole height */ height: calc(100vh - 100px) !important; max-height: calc(100vh - 100px) !important; } + #customizationui-widget-multiview box.panel-viewstack { /* since FF 113 */ + /* Use the whole height */ + height: 300px !important; + max-height: 300px !important; + } - #allTabsMenu-allTabsViewTabs { + #allTabsMenu-allTabsViewTabs, /* before FF 106 */ + #allTabsMenu-allTabsView-tabs { /* since FF 106 */ /* Make sure tabs with long titles don't exceed the all tabs menu */ width: 0; max-width: calc(100vw - 20px); diff --git a/src/userChrome/urlbar.css b/src/userChrome/urlbar.css index da669a1..83c7ce5 100644 --- a/src/userChrome/urlbar.css +++ b/src/userChrome/urlbar.css @@ -4,6 +4,7 @@ /* Reduce minimum window width */ #urlbar-container { min-width: 150px !important; + flex-shrink: 1 !important; } @media (max-width: 700px) { @@ -82,6 +83,14 @@ #PersonalToolbar { display: none; } + + /* If the bookmarks toolbar is configured to only show on the new tab page, + * Firefox makes the toolbar overlap the browser. When it's then hidden by + * the rule above, the urlbar is pushed off the bottom of the window. To + * prevent this, set the height of the overlapped toolbar to 0. */ + :root { + --bookmarks-toolbar-overlapping-browser-height: 0 !important; + } } /* Even though amazon is removed as search engine in policies.json, it gets