From 4cffee1e0672f1e889c163617cfdc5b2b8a57da6 Mon Sep 17 00:00:00 2001 From: fliegerjohn Date: Sun, 19 Nov 2023 17:55:44 +0100 Subject: [PATCH] cleaned from for us unneeded files --- .ci/lint.sh | 88 ----- .editorconfig | 19 - LICENSE | 373 ------------------ Makefile | 50 --- README.md | 130 ------ contrib/extract-search-engines.sh | 72 ---- ...arketos.mobile_config_firefox.metainfo.xml | 20 - src/common/header.css | 18 - src/mobile-config-autoconfig.js | 344 ---------------- 9 files changed, 1114 deletions(-) delete mode 100755 .ci/lint.sh delete mode 100644 .editorconfig delete mode 100644 LICENSE delete mode 100644 Makefile delete mode 100644 README.md delete mode 100755 contrib/extract-search-engines.sh delete mode 100644 org.postmarketos.mobile_config_firefox.metainfo.xml delete mode 100644 src/common/header.css delete mode 100644 src/mobile-config-autoconfig.js diff --git a/.ci/lint.sh b/.ci/lint.sh deleted file mode 100755 index 02175a8..0000000 --- a/.ci/lint.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/sh -e -# Copyright 2022 Oliver Smith -# SPDX-License-Identifier: MPL-2.0 -# -# As of writing, it seems that every existing CSS linter is either written in -# JS or ruby and has tons of dependencies... so instead of that let's use this -# simple shell script for now. This script needs find and GNU grep (for -P) and -# a shell that knows "local". - -TOPDIR="$(realpath "$(dirname "$(realpath "$0")")/..")" -CURRENT_FILE="" -EXIT_CODE=0 - -# $1: error message -# $2-n: arguments for grep -lint() { - # shellcheck disable=SC3043 - local msg="$1" - shift - - if grep -q "$@" "$CURRENT_FILE"; then - echo "ERROR: $msg" - echo "$CURRENT_FILE:" - grep -n "$@" "$CURRENT_FILE" - echo - EXIT_CODE=1 - fi -} - -lint_spdx() { - if ! grep -q "SPDX-License-Identifier" "$CURRENT_FILE"; then - echo "ERROR: missing SPDX-License-Identifier in $CURRENT_FILE" - echo - EXIT_CODE=1 - fi -} - -lint_spaces() { - lint \ - "tabs found, indent with 4 spaces instead" \ - -P '\t' - - lint \ - "indent with 4 spaces" \ - -P '^([ ]{1,3}|[ ]{5,7})[a-zA-Z\[\.\/\"]' - - lint \ - "spaces at the end of lines are not allowed" \ - -E ' $' -} - -lint_files() { - # shellcheck disable=SC3043 - local files="$(find src -name '*.css' -o -name '*.js' -o -name '*.json')" - - if [ -z "$files" ]; then - echo "ERROR: no files to lint found in current work dir" - exit 1 - fi - - for CURRENT_FILE in $files; do - case ${CURRENT_FILE##*.} in - css) - lint_spaces - lint_spdx - ;; - js) - lint_spaces - lint_spdx - ;; - json) - lint_spaces - ;; - esac - done -} - -cd "$TOPDIR" -lint_files - -if [ "$EXIT_CODE" -eq 0 ]; then - echo "No linting errors found :)" -else - echo "Please fix the linting errors above and consider configuring your" - echo "editor to use the .editorconfig file." -fi - -exit $EXIT_CODE diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index f82826f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,19 +0,0 @@ -; This file is for unifying the coding style for different editors and IDEs. -; Plugins are available for notepad++, emacs, vim, gedit, -; textmate, visual studio, and more. -; -; See http://editorconfig.org for details. - -# Top-most EditorConfig file. -root = true - -[*] -charset = utf-8 -end_of_line = lf -indent_size = 4 -indent_style = space -insert_final_newline = true -trim_trailing_whitespace = true - -[**/{*.sh,APKBUILD,Makefile}] -indent_style = tab diff --git a/LICENSE b/LICENSE deleted file mode 100644 index a612ad9..0000000 --- a/LICENSE +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/Makefile b/Makefile deleted file mode 100644 index c7f2953..0000000 --- a/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2023 Oliver Smith -# SPDX-License-Identifier: MPL-2.0 - -HEADER_FILE := src/common/header.css -USERCHROME_FILES := $(HEADER_FILE) $(sort $(wildcard src/userChrome/*.css)) -USERCONTENT_FILES := $(HEADER_FILE) $(sort $(wildcard src/userContent/*.css)) -DESTDIR := -FIREFOX_DIR := /usr/lib/firefox -FIREFOX_CONFIG_DIR := /etc/firefox - -all: out/userChrome.files out/userContent.files - -clean: - rm -rf out -out: - mkdir out - -out/userChrome.files: $(USERCHROME_FILES) out - for i in $(USERCHROME_FILES); do \ - echo "$$i" | cut -d/ -f 2-; \ - done > $@ - -out/userContent.files: $(USERCONTENT_FILES) out - for i in $(USERCONTENT_FILES); do \ - echo "$$i" | cut -d/ -f 2-; \ - done > $@ - -install: all - install -Dm644 src/policies.json \ - "$(DESTDIR)/$(FIREFOX_CONFIG_DIR)/policies/policies.json" - install -Dm644 src/mobile-config-prefs.js \ - "$(DESTDIR)/$(FIREFOX_DIR)/defaults/pref/mobile-config-prefs.js" - install -Dm644 src/mobile-config-autoconfig.js \ - "$(DESTDIR)/$(FIREFOX_DIR)/mobile-config-autoconfig.js" - install -Dm644 "out/userChrome.files" \ - -t "$(DESTDIR)/etc/mobile-config-firefox" - install -Dm644 "out/userContent.files" \ - -t "$(DESTDIR)/etc/mobile-config-firefox" - for dir in common userChrome userContent; do \ - for i in src/$$dir/*.css; do \ - install \ - -Dm644 \ - "$$i" \ - -t "$(DESTDIR)/etc/mobile-config-firefox/$$dir"; \ - done; \ - done - install -Dm644 org.postmarketos.mobile_config_firefox.metainfo.xml \ - "$(DESTDIR)/usr/share/metainfo/org.postmarketos.mobile_config_firefox.metainfo.xml" - -.PHONY: all clean install diff --git a/README.md b/README.md deleted file mode 100644 index b0090b9..0000000 --- a/README.md +++ /dev/null @@ -1,130 +0,0 @@ -# Mobile-Friendly Firefox Customizations for Librem 5 (mirror) - -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. - -This repository is maintained by Claudia Pellegrino (`@claui`). - -As a read-only mirror, it’s not accepting pull requests. The code in this -repository also does not replace a proper implementation in -[Firefox upstream](https://bugzilla.mozilla.org/show_bug.cgi?id=1579348) -*(interesting stuff happens in issues linked in "References")*. - ---- - -**Note:** Below follows a copy of the original `README.md` file from the upstream project [postmarketOS/mobile-config-firefox](https://gitlab.com/postmarketOS/mobile-config-firefox/). - ---- - -## What this config does - -* Adapt UI elements and "about:" pages to small screen sizes (when opened on - small screen) -* Enable mobile gestures -* Privacy tweaks: - * Disable search suggestions - * Disable Firefox studies - * Disable Telemetry - * Set DuckDuckGo as default search engine, remove other search engines except - for Wikipedia (only works in Firefox ESR, limitation of - [policies.json](https://github.com/mozilla/policy-templates/blob/cab6a5076c1d8e5a1574637709c19b54bdbd669e/README.md#searchengines--remove)) - * Install [uBlock origin](https://github.com/gorhill/uBlock) by default - ([why?](https://gitlab.com/postmarketOS/mobile-config-firefox/-/commit/160a1056c2cf35572157762f66174ea7c0b1db06)) -* Uncluttering: - * Disable built-in advertisements (e.g. hardcoded links for certain social - media sites on the start page) - * Disable "User Messaging" about new features etc. - -There's a -[screenshot thread](https://fosstodon.org/web/@ollieparanoid/107394745970284867) -of the `3.0.0_rc1` release. - -## For users: making changes - -As user, it is possible to override all options set by this project. Usually it -can be done in the preferences (which are now adaptive, so you can actually use -them on your phone). - -If it cannot be changed in preferences, look in -`/etc/firefox/policies/policies.json`. You can see the active policies while -Firefox is running in `about:policies`. The uBlock origin add-on for example, -is getting installed through `policies.json` and can be removed in that file -if you do not want it. Without editing the file, it can only be disabled in the -add-on settings, and not removed, this is a limitation of `policies.json`. - -Feel free to -[create an issue](https://gitlab.com/postmarketOS/mobile-config-firefox/-/issues) -if you run into problems. Or even better, attempt to fix the problem yourself -(see development instructions below) and submit a -[merge request](https://gitlab.com/postmarketOS/mobile-config-firefox/-/merge_requests). - -## Contributing changes to userChrome -Firefox' developer tools include a -[remote debugger](https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging), -which even has the "pick an element" feature. You will be able to click that -button on your PC, then tap on an element of the Firefox UI on your phone, and -then you will see the HTML code and CSS properties on your PC just as if it was -a website. So this is highly recommended when contributing changes to -`userChrome.css`. - -* Connect your phone and your PC to the same network (Wi-Fi or USB network) -* On your phone, open Firefox and `about:config`: - * Change `devtools.chrome.enabled` to `true` - * Change `devtools.debugger.remote-enabled` to `true` - * The debugger will only listen on localhost by default. If you know what you - are doing, you may set `devtools.debugger.force-local` to `false`, so it - listens on all interfaces. Otherwise you'll need something like an SSH - tunnel. - * Close firefox -* Connect to your phone via [SSH](https://wiki.postmarketos.org/wiki/SSH) - * Set up environment variables properly, so you can start programs (one lazy - way to do it, is `tmux` on your phone in the terminal, then `tmux a` in - SSH) - * Run `firefox --start-debugger-server 6000` (or another port if you desire) -* Run Firefox on your PC - * Go to `about:debugging` - * Add your phone as "network location" (`172.16.42.1:6000` if connected through USB Network) - * Press the connect button on the left - * If it does not work, check if a firewall on your phone is blocking the port - (i.e. [nftables](https://wiki.postmarketos.org/wiki/Nftables) in postmarketOS). -* On your phone - * Confirm the connection on your phone's screen - * If the button is not visible on the screen, try switching to a terminal - virtual keyboard, hit "tab" three times and then return -* On your PC - * Scroll down to Processes, Main Process, and click "Inspect" - * Now use the "Pick an element" button as described in the introduction. Find - the `userChrome.css` file in the "Style editor" tab and edit it as you - like. - * Consider copy pasting the contents to a text editor every now and then, so - you don't lose it when closing Firefox by accident. - -Note that after making changes to CSS files, and deploying them on your -system (`make install`), you might need to restart firefox _twice_ before -changes are applied. - -## Log file - -The `src/mobile-config-autoconfig.js` script generates `userChrome.css` and -`userContent.css` while Firefox starts. It logs to your Firefox profile -directory, follow the log file with: - -``` -$ tail -F $(find ~/.mozilla -name mobile-config-firefox.log) -``` - -## Coding guidelines - -* Don't make longer lines than 79 columns where possible (like in PEP-8) -* Use 4 spaces for indent in all files, except for shell scripts (use tabs - there). Consider configuring your editor to use `.editorconfig`, then it gets - configured automatically. -* Linter: `.ci/lint.sh` (consider setting it as pre-commit hook, requires GNU - grep) - -## Additional resources -* [How to use the Firefox Browser Toolbox](https://developer.mozilla.org/en-US/docs/Tools/Browser_Toolbox) -* [firefox-csshacks](https://github.com/MrOtherGuy/firefox-csshacks/) -* [FirefoxCSS subreddit](https://www.reddit.com/r/FirefoxCSS/) diff --git a/contrib/extract-search-engines.sh b/contrib/extract-search-engines.sh deleted file mode 100755 index b1a8f5a..0000000 --- a/contrib/extract-search-engines.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh -e -# Copyright 2022 Oliver Smith -# SPDX-License-Identifier: MPL-2.0 -# -# Extract the search engine names found in your current Firefox installation, -# and create a list suitable for policies.json that removes all of them except -# for what's in remove_allowed_dirs(). Note that SearchEngines can only be -# configured via policies.json in the ESR version of firefox. -# Related: https://github.com/mozilla/policy-templates/blob/master/README.md - -remove_allowed_dirs() { - rm -rf \ - ddg \ - wikipedia -} - -get_names() { - grep \ - '"name":' \ - */manifest.json \ - | cut -d '"' -f 4 \ - | grep -v '__MSG_extensionName__' \ - | grep -v '^form$' -} - -get_names_localized() { - grep \ - -A1 \ - '"extensionName":' \ - */_locales/*/messages.json \ - | grep '"message":' \ - | cut -d '"' -f 4 -} - -get_names_all_sorted() { - (get_names; get_names_localized) | sort -u -} - -print_json() { - local first=1 - - echo ' "SearchEngines": {' - echo ' "Default": "DuckDuckGo",' - echo ' "Remove": [' - - get_names_all_sorted | while IFS= read -r i; do - if [ "$first" -eq 1 ]; then - first=0 - else - echo "," - fi - printf " \"$i\"" - done - - echo '' - echo ' ]' - echo ' },' -} - - -OMNI="/usr/lib/firefox/browser/omni.ja" -TMPDIR="$(mktemp -d "/tmp/extract-search-engines-XXXXXX")" -cd "$TMPDIR" - -unzip -q "$OMNI" -cd "chrome/browser/search-extensions" - -remove_allowed_dirs -print_json - -cd ~ -rm -r "$TMPDIR" diff --git a/org.postmarketos.mobile_config_firefox.metainfo.xml b/org.postmarketos.mobile_config_firefox.metainfo.xml deleted file mode 100644 index 765e6c9..0000000 --- a/org.postmarketos.mobile_config_firefox.metainfo.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - org.postmarketos.mobile_config_firefox - - Mobile Config for Firefox - Mobile and privacy friendly configuration for Firefox (distro-independent) - - CC0-1.0 - MPL-2.0 - - - org.mozilla.firefox - - - -

- UI optimizations to allow using Firefox on mobile devices (i.e. small touch screen), including two finger zoom and enforcing of mobile user agent. Privacy enhancements such as disabled search suggestions, disabled Firefox studies, disabled Telemetry and DuckDuckGo as default search engine. -

-
-
diff --git a/src/common/header.css b/src/common/header.css deleted file mode 100644 index f564a11..0000000 --- a/src/common/header.css +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2023 Oliver Smith, Arnaud Ferraris - * SPDX-License-Identifier: MPL-2.0 - * _ _ _ __ _ - * _ __ ___ ___ | |__ (_) | ___ ___ ___ _ __ / _(_) __ _ - * | '_ ` _ \ / _ \| '_ \| | |/ _ \_____ / __/ _ \| '_ \| |_| |/ _` | - * | | | | | | (_) | |_) | | | __/_____| (_| (_) | | | | _| | (_| | - * |_| |_| |_|\___/|_.__/|_|_|\___| \___\___/|_| |_|_| |_|\__, | - * mobile-config-firefox |___/ - * https://gitlab.com/postmarketOS/mobile-config-firefox/ - * - * WARNING: DO NOT EDIT THE COPY OF THIS FILE LOCATED IN YOUR USER PROFILE! - * - * It will be overwritten on upgrade. You should edit the files located in - * /etc/mobile-config-firefox/ instead (most package managers won't replace - * files under /etc if they've been edited). Or alternatively, consider cloning - * mobile-config-firefox.git and editing the separate CSS files there. - * Patches for useful additions welcome! - */ diff --git a/src/mobile-config-autoconfig.js b/src/mobile-config-autoconfig.js deleted file mode 100644 index 5693847..0000000 --- a/src/mobile-config-autoconfig.js +++ /dev/null @@ -1,344 +0,0 @@ -// Copyright 2023 Arnaud Ferraris, Oliver Smith -// SPDX-License-Identifier: MPL-2.0 -// -// Generate and update userChrome.css and userContent.css for the user's -// profile from CSS fragments in /etc/mobile-config-firefox, depending on the -// installed Firefox version. Set various defaults for about:config options in -// set_default_prefs(). -// -// Log file: -// $ find ~/.mozilla -name mobile-config-firefox.log -// -// This is a Firefox autoconfig file: -// https://support.mozilla.org/en-US/kb/customizing-firefox-using-autoconfig -// -// The XPCOM APIs used here are the same as old Firefox add-ons used, and the -// documentation for them has been removed (can we use something else? patches -// welcome). They appear to still work fine for autoconfig scripts. -// 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; -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; -var g_updated = false; -var g_fragments_cache = {}; // cache for css_file_get_fragments() -var g_logFileStream; -var g_chromeDir; // nsIFile object for the "chrome" dir in user's profile - - -function write_line(ostream, line) { - line = line + "\n" - ostream.write(line, line.length); -} - -// Create /chrome/ directory if not already present -function chrome_dir_init() { - g_chromeDir = Services.dirsvc.get("ProfD", Ci.nsIFile); - g_chromeDir.append("chrome"); - if (!g_chromeDir.exists()) { - g_chromeDir.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY); - } -} - -function log_init() { - var mode = FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE | FileUtils.MODE_APPEND; - var logFile = g_chromeDir.clone(); - logFile.append("mobile-config-firefox.log"); - g_logFileStream = FileUtils.openFileOutputStream(logFile, mode); -} - -function log(line) { - var date = new Date().toISOString().replace("T", " ").slice(0, 19); - line = "[" + date + "] " + line; - write_line(g_logFileStream, line); -} - -// Debug function for logging object attributes -function log_obj(obj) { - var prop; - var value; - - for (var prop in obj) { - try { - value = obj[prop]; - } catch(e) { - value = e; - } - log(" - " + prop + ": " + value); - } -} - -function get_firefox_version() { - return Services.appinfo.version.split(".")[0]; -} - -function get_firefox_version_previous() { - var file = g_chromeDir.clone(); - file.append("ff_previous.txt"); - - if (!file.exists()) - return "unknown"; - - var istream = Cc["@mozilla.org/network/file-input-stream;1"]. - createInstance(Components.interfaces.nsIFileInputStream); - istream.init(file, 0x01, 0444, 0); - istream.QueryInterface(Components.interfaces.nsILineInputStream); - - var line = {}; - istream.readLine(line); - istream.close(); - - return line.value.trim(); -} - -function set_firefox_version_previous(new_version) { - log("Updating previous Firefox version to: " + new_version); - - var file = g_chromeDir.clone(); - file.append("ff_previous.txt"); - - var ostream = Cc["@mozilla.org/network/file-output-stream;1"]. - createInstance(Components.interfaces.nsIFileOutputStream); - ostream.init(file, 0x02 | 0x08 | 0x20, 0644, 0); - write_line(ostream, new_version); - ostream.close(); -} - -function trigger_firefox_restart() { - log("Triggering Firefox restart"); - var appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup); - appStartup.quit(Ci.nsIAppStartup.eForceQuit | Ci.nsIAppStartup.eRestart); -} - -// Check if a CSS fragment should be used or not, depending on the current -// Firefox version. -// fragment: e.g. "userChrome/popups.before-ff-108.css" -// returns: true if it should be used, false if it must not be used -function css_fragment_check_firefox_version(fragment) { - if (fragment.indexOf(".before-ff-") !== -1) { - var before_ff_version = fragment.split("-").pop().split(".")[0]; - if (g_ff_version >= before_ff_version) { - log("Fragment with FF version check not included: " + fragment); - return false; - } else { - log("Fragment with FF version check included: " + fragment); - return true; - } - } - - return true; -} - -// Get an array of paths to the fragments for one CSS file -// name: either "userChrome" or "userContent" -function css_file_get_fragments(name) { - if (name in g_fragments_cache) - return g_fragments_cache[name]; - - var ret = []; - var path = "/etc/mobile-config-firefox/" + name + ".files"; - log("Reading fragments from file: " + path); - var file = new FileUtils.File(path); - - var istream = Cc["@mozilla.org/network/file-input-stream;1"]. - createInstance(Components.interfaces.nsIFileInputStream); - istream.init(file, 0x01, 0444, 0); - istream.QueryInterface(Components.interfaces.nsILineInputStream); - - var has_more; - do { - var line = {}; - has_more = istream.readLine(line); - if (css_fragment_check_firefox_version(line.value)) - ret.push("/etc/mobile-config-firefox/" + line.value); - - } while (has_more); - - istream.close(); - - g_fragments_cache[name] = ret; - return ret; -} - -// Create a nsIFile object with one of the CSS files in the user's profile as -// path. The file doesn't need to exist at this point. -// name: either "userChrome" or "userContent" -function css_file_get(name) { - var ret = g_chromeDir.clone(); - ret.append(name + ".css"); - return ret; -} - -// Delete either userChrome.css or userContent.css inside the user's profile if -// they have an older timestamp than the CSS fragments (or list of CSS -// fragments) installed system-wide. -// name: either "userChrome" or "userContent" -// file: return of css_file_get() -function css_file_delete_outdated(name, file) { - var depends = css_file_get_fragments(name).slice(); /* copy the array */ - depends.push("/etc/mobile-config-firefox/" + name + ".files"); - for (var i in depends) { - var depend = depends[i]; - var file_depend = new FileUtils.File(depend); - - if (file.lastModifiedTime < file_depend.lastModifiedTime) { - log("Removing outdated file: " + file.path + " (newer: " - + depend + ")"); - file.remove(false); - return; - } - } - - log("File is up-to-date: " + file.path); - return; -} - -// Create userChrome.css / userContent.css in the user's profile, based on the -// CSS fragments stored in /etc/mobile-config-firefox. -// name: either "userChrome" or "userContent" -// file: return of css_file_get() -function css_file_merge(name, file) { - log("Creating CSS file from fragments: " + file.path); - - var ostream = Cc["@mozilla.org/network/file-output-stream;1"]. - createInstance(Components.interfaces.nsIFileOutputStream); - ostream.init(file, 0x02 | 0x08 | 0x20, 0644, 0); - - var fragments = css_file_get_fragments(name); - for (var i in fragments) { - var line; - var fragment = fragments[i]; - log("- " + fragment); - write_line(ostream, "/* === " + fragment + " === */"); - - var file_fragment = new FileUtils.File(fragment); - - var istream = Cc["@mozilla.org/network/file-input-stream;1"]. - createInstance(Components.interfaces.nsIFileInputStream); - istream.init(file_fragment, 0x01, 0444, 0); - istream.QueryInterface(Components.interfaces.nsILineInputStream); - - var has_more; - do { - var line = {}; - has_more = istream.readLine(line); - write_line(ostream, line.value); - } while (has_more); - - istream.close(); - } - - ostream.close(); - g_updated = true; -} - -function css_files_update() { - g_ff_version = get_firefox_version(); - var ff_previous = get_firefox_version_previous(); - log("Firefox version: " + g_ff_version + " (previous: " + ff_previous + ")"); - - var names = ["userChrome", "userContent"]; - for (var i in names) { - var name = names[i]; - var file = css_file_get(name); - - if (file.exists()) { - if (g_ff_version != ff_previous) { - log("Removing outdated file: " + file.path + " (Firefox" + - " version changed)"); - file.remove(false); - } else { - css_file_delete_outdated(name, file); - } - } - - if (!file.exists()) { - css_file_merge(name, file); - } - } - - if (g_ff_version != ff_previous) - 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 - // clicking the urlbar. - defaultPref('browser.urlbar.suggest.topsites', false); - - // Do not suggest search engines. Even though amazon is removed via - // policies.json, it gets installed shortly after the browser is opened. - // With this option, at least there is no big "Search with Amazon" message - // in the urlbar results as soon as typing the letter "a". - defaultPref('browser.urlbar.suggest.engines', false); - - // Show about:home in new tabs, so it's not just a weird looking completely - // empty page. - defaultPref('browser.newtabpage.enabled', true); - - // Disable "Firefox View" feature by default. It's a pinned tab that allows - // to "pick up" tabs from other devices after registering an account, and - // 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() { - log("Running mobile-config-autoconfig.js"); - css_files_update(); - - // Restart Firefox immediately if one of the files got updated - if (g_updated == true) - trigger_firefox_restart(); - else - set_default_prefs(); - - log("Done"); -} - -chrome_dir_init(); -log_init(); -try { - main(); -} catch(e) { - log("main() failed: " + e); - - // Let Firefox display the generic error message that something went wrong - // in the autoconfig script. - error; -} -g_logFileStream.close();