Switch to Firefox

Previous

大学刚用电脑时,估计用了半年的 IE(和 Windows),后来转 Ubuntu 后,自然就是 Firefox。 没多久 Google Chrome 出来了,印象最深大概就是这个漫画,当时真是耳目一新, 从此简洁的风格风靡各大浏览器,最明显就是地址栏和搜索栏放到一起并占据显要位置。

后来就是尽管 Chrome 不崩溃了(当然这个锅主要是 IE 的),然而内存耗用却越来越大,再加上 Chrome 是基于 Chromium 开发, 感觉没有 Firefox 活跃(估计我主要被每天推送mozilla blogmozila hacks的文章而这么觉得)。 去年年末 Mozilla 开始大肆宣传 Quantum 新版本,什么 Off-Main-Thread Painting,新的 CSS 引擎 Stylo,Webassembly Streaming Compiler,以及用 Rust 写的 WebRender 等等, 我就自然重回 Firefox 的怀抱了。

Migration

Switching from Chrome to Firefox, 最重要是第一步,等把配置导入完了再删 Chrome 。

数据主要就是 history 和 bookmark 了,密码目前我是 lastpass 管理,Chrome 那边还留了冷备。 具体密码管理见Password Manager

迁移具体过程也是无痛,如这儿所说,Switching over to Firefox Quantum was relatively painless,当然我对 UI 改变基本无感,即使有,也能通过自定义解决。

Add-ons

这个两年前 Mozilla 就说要迁移到类似 Chrome 的 Web Extension,放弃旧的 XUL 体系,My new worry about Firefox 56 and the addons that I care about。 那篇博文的作者也列出了自己的插件, My current set of Firefox Quantum (57+) addonsThe addons that I would likely use with Firefox Quantum (57+)

我以前印象比较深刻的就两个,一个是 DownThemAll!,另外一个是 AutoProxy,总之记得 logo 上有一个福字。当然现在各种原因都没法用了~

现在主要用的插件有:

  1. Last Password 密码管理,但 Android 版本不可用(LastPass quietly deprecates Firefox for Android extensionCan't use LastPass/Bitwarden with Firefox for Android anymore ?!
  2. Firefox Multi-Account Containers 基本就是你可以把各个网站分组隔离开来,superuser 上有个类似的问题Open Link in different Profile in Firefox
  3. Vimium 以前用 Vimperator,后来用 Chrome 也有,迁移到 Firefox 时发现也出了不稳定版。
  4. Adblock Plus 广告屏蔽,流行必备装备。
  5. Save and Restore Tabs in Firefox with Tab Stash - gHacks Tech News

自从发现了 Firefox Multi-Account Containers 这个好东西后,就想着官方是否还有其他精品, 写了个脚本发现官方出品 extension 总共也没几个...

firefox-addon.py
import random
import datetime
import requests
import jwt
JWT_ISSUER = 'user:xxxxxxx:xx'
JWT_SECRET = 'xxx'

def main():
    url = 'https://addons.mozilla.org/api/v3/addons/search/'
    while True:
        payload = {
            'iss': JWT_ISSUER,
            'jti': f'{random.random()}',
            'iat': datetime.datetime.utcnow(),
            'exp': datetime.datetime.utcnow() + datetime.timedelta(seconds=50)
        }
        encoded = jwt.encode(payload, JWT_SECRET, algorithm='HS256')
        resp = requests.get(url, params={'author': 'mozilla'}, headers={'Authorization': f'JWT {encoded}'})
        for item in resp.json().get('results'):
            name = item.get('name', {}).get('en-US', '')
            type_ = item.get('type')
            # http://addons-server.readthedocs.io/en/latest/topics/api/addons.html#addon-detail-type
            if type_ == 'extension':
                print(name, item.get('url'))
        if not resp.json().get('next'):
            break
        url = resp.json().get('next')


if __name__ == '__main__':
    main()

当然,有时你会发现某些插件无法删除,请服用Cannot remove an add-on (extension or theme)

Chrome Mod

首先这个 tab 方块没法忍,发现有人跟我一样,photon-australis

打开 about:support 或者 about:profiles 查找 Profile Folder 或者 Root Directory 的位置, 比如我的 MacOS 上是 $HOME/Library/Application Support/Firefox/Profiles/xxxx.default,把 Git 仓库代码(我选择的是 Default 主题)拷贝到 chrome/userChrome.css 里就好。

Reader View 非常适合阅读,但是默认宽度太窄,可以按照如下修改。

reader-view-customize
$ cat chrome/userContent.css
/* selectors are from aboutReader.css */
.container.content-width7 {
  max-width: 48em !important;
}

.container.content-width8 {
  max-width: 48em !important;
}

.container.content-width9 {
  max-width: 48em !important;
}

Sync

  1. Google shuts off Chrome Sync API for third-party browsers on Android, citing a security vulnerability
  2. Is there an API to access Chrome Sync data
  3. HELP : Firefox Sync with SSL
  4. For the Paranoids: Install Your Own Firefox Sync Server
  5. User Services/Sync/SetupSyncNext, CloudServices/Sync/Client Log Debugging
  6. about:sync-log missing in android firefox
adb-debug
$ # adb shell setprop log.tag.FxAccounts DEBUG
$ adb logcat -s FxAccounts
05-28 22:39:47.538 I/FxAccounts( 6982): firefox :: FirefoxAccounts :: Requesting sync.
05-28 22:39:47.539 I/FxAccounts( 6982): firefox :: FirefoxAccounts :: Sync options -- scheduling now: true
05-28 22:39:47.540 I FxAccounts( 6982): firefox :: FxAccountSyncAdapter :: Not syncing FxAccount XXXXXXXX@XXXXX.XXX: minimum interval not met.

为了安全着想,我还是不自建 Sync。 我不喜欢的 Firefox 同步

About Protocol

Firefox and the "about" protocol

  1. about:about
  2. about:networking
  3. about:sync-log

不像 Chrome,可以直接进 chrome://net-internals#dns 直接 Clear host cache,Firefox 则需要修改 config,Firefox invalidate dns cache

Configuration

Firefox configuration hardening Firefox 作为互联网先锋,当然少不了,A history of Fingerprinting protection in Firefox。 更高级的设置,可以参考 Firefox Configuration Guide for Privacy Freaks and Performance Buffs,我就暂时打住,不然这嵌套一层层调用下去会无休止。

AutoConfig

omni.ja

DoH & Network

Firefox, DNS over HTTPS and a controversial Shield Study
DoH 引发 panic/crash 的相关 bug: #1450583, #1450630[,#1441131

user_pref

<!-- markdownlint-disable MD034 >

$ cat prefs.js |grep network.trr
user_pref("network.trr.mode", 3); // 2
user_pref("network.trr.uri", "https://example.com/dns-query"); // https://mozilla.cloudflare-dns.com/dns-query

#user_pref("network.trr.bootstrapAddress", "x.x.x.x");
user_pref("network.trr.blacklist-duration", 300);

$ cat prefs.js |grep network.proxy
user_pref("network.proxy.autoconfig_url", "https://example.com/a");
user_pref("network.proxy.type", 2);

Ad-blocking

Adblock Plus filters explained

  1. network.http.sendRefererHeader
  2. privacy.resistFingerprinting

在页面输入框右键可以添加搜索

  1. Add custom search engine, github
  2. How to Add Any Search Engine to Your Web Browser
  3. Add custom search engines to Firefox
  4. Manage my default search engines in Firefox for Android

Translation

当然就没有 Chrome 那种自动检测语言提示翻译了。

  1. Firefox built-in translation not working
  2. Mozilla working on Google Translate integration in Firefox
  3. How to add translate feature to Firefox Mozilla to use Microsoft Translator for Translations in Firefox

最后我使用的是Google Translator for Firefox

Vimum

Android

  1. 安装 Privacy Badger 和 Adblock Plus,如果无法在线安装,可以下载 xpi,然后浏览器通过 file 协议打开下载文件夹安装。
  2. Adblock Plus 选项里增加过滤列表 EasyList China + EasyList。
  3. 设置里启用 Tracking Protection。

Comparison

  1. 查看 CPU/内存使用没有 Chrome 那么方便,只能去 about:memory 里 dump,组织还比较不清晰,哪个 Tab 消耗多少 CPU 内存没法一眼看出来。
  2. 内置的截图功能非常赞,堪比锤子手机上的滚动截图(话说 Android P 好像也要集成截图编辑功能了)。
  3. Tab 同步功能跟 Chrome 一样好用,开始以为 firefox 不至于被🦀,但是没想到祖国的关心无处不在。
  4. 相比 Chrome,Firefox 移动端没有整页自动翻译了,这个有时看到日文或者俄文的只能单独处理了。
  5. Chrome 移动端会提示启用 Mobile Friendly View,但是 Firefox Android 可以启用 Reader View,不过效果差不多。1

FAQ

  1. 发现 Google Voice 页面一直加载失败,Not loading on Firefox, 需要启用 media.peerconnection.enabled 。
  2. 每次从 Firefox 里拷贝出来的 URL 如果带有 Unicode 字符就被转义了,变成一大长串%号, How do I copy hyperlinks in non-encoded format in Firefox? [duplicate],修改 browser.urlbar.decodeURLsOnCopy 为 false。javascript:(function(){prompt("a", \${document.title}`);})()`
  3. delete auto complete entry

Known Issues

  1. #868370 无法导入客户端证书,只能启个 web server,设置正确的 MIME type
  2. #1443259 FoxyProxy 无法支持 PAC 文件。
  3. How to open Links (e.g. YouTube, Autoscout) in native App instead of browser??
  4. Firefox screenshot node viewport only,例如截图 outlook web 页面中的邮件。
  5. Firefox 未集成 Google Translate
  6. Firefox 搜索时如果网络不好,地址栏为空
  7. Firefox Sync 无法设置代理(跟 Android Sync background 有关)

Reference

  1. Chromium 还是 FireFox?

Comments