firefox-custom 0.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. firefox_custom/__init__.py +3 -0
  2. firefox_custom/__main__.py +5 -0
  3. firefox_custom/assets.py +136 -0
  4. firefox_custom/cli.py +571 -0
  5. firefox_custom/config.py +92 -0
  6. firefox_custom/data/extensions.toml +53 -0
  7. firefox_custom/docs.py +112 -0
  8. firefox_custom/features/address-bar-favicon/autoconfig.js +58 -0
  9. firefox_custom/features/address-bar-favicon/chrome.css +18 -0
  10. firefox_custom/features/address-bar-favicon/manifest.toml +10 -0
  11. firefox_custom/features/alt-no-menu/manifest.toml +12 -0
  12. firefox_custom/features/alt-no-menu/prefs.js +1 -0
  13. firefox_custom/features/azerty-tab-shortcuts/keys.json +38 -0
  14. firefox_custom/features/azerty-tab-shortcuts/manifest.toml +11 -0
  15. firefox_custom/features/clean-new-tab/manifest.toml +10 -0
  16. firefox_custom/features/clean-new-tab/prefs.js +4 -0
  17. firefox_custom/features/context-menus/autoconfig.js +71 -0
  18. firefox_custom/features/context-menus/chrome.css +154 -0
  19. firefox_custom/features/context-menus/manifest.toml +10 -0
  20. firefox_custom/features/gamma22-colors/manifest.toml +11 -0
  21. firefox_custom/features/gamma22-colors/prefs.js +4 -0
  22. firefox_custom/features/hidden-bookmarks-bar/manifest.toml +10 -0
  23. firefox_custom/features/hidden-bookmarks-bar/prefs.js +1 -0
  24. firefox_custom/features/pinned-tab-close/autoconfig.js +99 -0
  25. firefox_custom/features/pinned-tab-close/manifest.toml +10 -0
  26. firefox_custom/features/pinned-tab-width/manifest.toml +15 -0
  27. firefox_custom/features/pinned-tab-width/options/width/default/.gitkeep +0 -0
  28. firefox_custom/features/pinned-tab-width/options/width/large/chrome.css +43 -0
  29. firefox_custom/features/pinned-tab-width/options/width/large/prefs.js +1 -0
  30. firefox_custom/features/pinned-tab-width/options/width/larger/chrome.css +43 -0
  31. firefox_custom/features/pinned-tab-width/options/width/larger/prefs.js +1 -0
  32. firefox_custom/features/restore-session/manifest.toml +10 -0
  33. firefox_custom/features/restore-session/prefs.js +1 -0
  34. firefox_custom/features/tab-sound-indicator/chrome.css +132 -0
  35. firefox_custom/features/tab-sound-indicator/manifest.toml +10 -0
  36. firefox_custom/features/urlbar-tweaks/manifest.toml +10 -0
  37. firefox_custom/features/urlbar-tweaks/prefs.js +3 -0
  38. firefox_custom/features/web-apps/manifest.toml +10 -0
  39. firefox_custom/features/web-apps/prefs.js +1 -0
  40. firefox_custom/manifest.py +114 -0
  41. firefox_custom/presets/chrome-parity.toml +19 -0
  42. firefox_custom/profiles.py +161 -0
  43. firefox_custom/system.py +157 -0
  44. firefox_custom/templates/switching-from-chrome.md +85 -0
  45. firefox_custom/wizard.py +148 -0
  46. firefox_custom-0.1.3.dist-info/METADATA +108 -0
  47. firefox_custom-0.1.3.dist-info/RECORD +50 -0
  48. firefox_custom-0.1.3.dist-info/WHEEL +4 -0
  49. firefox_custom-0.1.3.dist-info/entry_points.txt +2 -0
  50. firefox_custom-0.1.3.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,3 @@
1
+ """firefox-custom: Chrome-parity customizations for Firefox."""
2
+
3
+ __version__ = "0.1.3"
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ sys.exit(main())
@@ -0,0 +1,136 @@
1
+ """Assets layer: files generated into the user data directory (such as the ICC profile).
2
+
3
+ Assets are generated at install time, so nothing binary is shipped. Which files
4
+ we own is remembered in a small state file, so a later install, a disabled
5
+ feature or an uninstall removes exactly what we wrote.
6
+ """
7
+ import json
8
+ import os
9
+ import struct
10
+ import sys
11
+ from pathlib import Path
12
+
13
+ STATE_NAME = "firefox-custom-assets.json"
14
+ RESTORE_NAME = "firefox-custom-assets-restore.json" # foreign files we replaced -> their backup
15
+
16
+
17
+ def data_dir() -> Path:
18
+ """User data directory (FIREFOX_CUSTOM_DATA_DIR, then XDG_DATA_HOME, then ~/.local/share)."""
19
+ override = os.environ.get("FIREFOX_CUSTOM_DATA_DIR")
20
+ if override:
21
+ return Path(override)
22
+ if sys.platform == "win32":
23
+ base = os.environ.get("LOCALAPPDATA") or Path.home() / "AppData" / "Local"
24
+ elif sys.platform == "darwin":
25
+ base = Path.home() / "Library" / "Application Support"
26
+ else:
27
+ base = os.environ.get("XDG_DATA_HOME") or Path.home() / ".local" / "share"
28
+ return Path(base)
29
+
30
+
31
+ def _fixed(v: float) -> bytes:
32
+ return struct.pack(">i", round(v * 65536))
33
+
34
+
35
+ def _xyz(x: float, y: float, z: float) -> bytes:
36
+ return b"XYZ \0\0\0\0" + _fixed(x) + _fixed(y) + _fixed(z)
37
+
38
+
39
+ def _desc(s: str) -> bytes:
40
+ a = s.encode("ascii") + b"\0"
41
+ return b"desc\0\0\0\0" + struct.pack(">I", len(a)) + a + b"\0" * (4 + 4 + 2 + 1 + 67)
42
+
43
+
44
+ def gamma22_icc() -> bytes:
45
+ """A minimal ICC v2 display profile: sRGB primaries, pure gamma 2.2 (deterministic)."""
46
+ curve = b"curv\0\0\0\0" + struct.pack(">IH", 1, round(2.2 * 256))
47
+ tags = [
48
+ (b"desc", _desc("sRGB primaries, gamma 2.2")),
49
+ (b"cprt", b"text\0\0\0\0Public domain\0"),
50
+ (b"wtpt", _xyz(0.9505, 1.0, 1.0891)),
51
+ # sRGB colorants, adapted to the D50 profile connection space
52
+ (b"rXYZ", _xyz(0.43607, 0.22249, 0.01392)),
53
+ (b"gXYZ", _xyz(0.38515, 0.71687, 0.09710)),
54
+ (b"bXYZ", _xyz(0.14307, 0.06061, 0.71410)),
55
+ (b"rTRC", curve), (b"gTRC", curve), (b"bTRC", curve),
56
+ ]
57
+ offset = 128 + 4 + 12 * len(tags)
58
+ table, body = struct.pack(">I", len(tags)), b""
59
+ for sig, tag in tags:
60
+ table += sig + struct.pack(">II", offset + len(body), len(tag))
61
+ body += tag + b"\0" * (-len(tag) % 4)
62
+ size = offset + len(body)
63
+ header = (struct.pack(">I4sI4s4s4s", size, b"\0" * 4, 0x02400000, b"mntr", b"RGB ", b"XYZ ")
64
+ + struct.pack(">6H", 2026, 11, 30, 0, 0, 0) + b"acsp" + b"\0" * 28
65
+ + _fixed(0.9642) + _fixed(1.0) + _fixed(0.8249))
66
+ header += b"\0" * (128 - len(header))
67
+ return header + table + body
68
+
69
+
70
+ # asset name -> (folder under the data directory, generator)
71
+ ASSETS = {"srgb-gamma22-firefox.icc": ("icc", gamma22_icc)}
72
+
73
+
74
+ def asset_path(name: str) -> Path:
75
+ return data_dir() / ASSETS[name][0] / name
76
+
77
+
78
+ def _state_path() -> Path:
79
+ return data_dir() / STATE_NAME
80
+
81
+
82
+ def read_state() -> list:
83
+ try:
84
+ return json.loads(_state_path().read_text(encoding="utf-8"))
85
+ except (OSError, json.JSONDecodeError):
86
+ return []
87
+
88
+
89
+ def _restore_path() -> Path:
90
+ return data_dir() / RESTORE_NAME
91
+
92
+
93
+ def _read_restore() -> dict:
94
+ try:
95
+ return json.loads(_restore_path().read_text(encoding="utf-8"))
96
+ except (OSError, json.JSONDecodeError):
97
+ return {}
98
+
99
+
100
+ def apply(names: list, backup) -> None:
101
+ """Make the data directory hold exactly the assets `names` (and no others of ours).
102
+
103
+ `backup(path)` saves a file before it is replaced or removed and returns the copy.
104
+ A foreign file we replace is put back once its asset is no longer wanted.
105
+ """
106
+ owned = read_state()
107
+ replaced = _read_restore()
108
+ wanted = {str(asset_path(n)): ASSETS[n][1] for n in names}
109
+ for old in owned:
110
+ if old not in wanted and Path(old).exists():
111
+ backup(Path(old))
112
+ Path(old).unlink()
113
+ for path_str, generate in wanted.items():
114
+ path, data = Path(path_str), generate()
115
+ if path.exists():
116
+ if path.read_bytes() == data:
117
+ continue
118
+ if path_str not in owned:
119
+ replaced.setdefault(path_str, str(backup(path)))
120
+ path.parent.mkdir(parents=True, exist_ok=True)
121
+ path.write_bytes(data)
122
+ for path_str in [p for p in replaced if p not in wanted]:
123
+ saved = Path(replaced.pop(path_str))
124
+ if saved.exists():
125
+ Path(path_str).parent.mkdir(parents=True, exist_ok=True)
126
+ Path(path_str).write_bytes(saved.read_bytes())
127
+ if replaced:
128
+ _restore_path().parent.mkdir(parents=True, exist_ok=True)
129
+ _restore_path().write_text(json.dumps(replaced), encoding="utf-8")
130
+ elif _restore_path().exists():
131
+ _restore_path().unlink()
132
+ if wanted:
133
+ _state_path().parent.mkdir(parents=True, exist_ok=True)
134
+ _state_path().write_text(json.dumps(sorted(wanted)), encoding="utf-8")
135
+ elif _state_path().exists():
136
+ _state_path().unlink()