firefox-extensions: add default-zoom so that new tabs are readable by default

This commit is contained in:
2024-12-01 22:27:23 +00:00
parent 8a5629ec13
commit ec29c399f7
6 changed files with 74 additions and 0 deletions

View File

@@ -27,6 +27,9 @@ in
# package = pkgs.firefox-extensions.ctrl-shift-c-should-copy;
# enable = lib.mkDefault false; # prefer patching firefox source code, so it works in more places
# };
default-zoom = {
enable = lib.mkDefault true;
};
# ether-metamask = {
# enable = lib.mkDefault false; # until i can disable the first-run notification
# };

View File

@@ -248,6 +248,8 @@ in
// uidensity=2 gives more padding around UI elements.
// source: <https://codeberg.org/user0/Mobile-Friendly-Firefox>
defaultPref("browser.uidensity", 2);
// layout.css.devPixelsPerPx: acts as a global scale (even for the chrome)
// defaultPref("layout.css.devPixelsPerPx", 1.5);
// open external URIs/files via xdg-desktop-portal.
defaultPref("widget.use-xdg-desktop-portal.mime-handler", 1);

View File

@@ -0,0 +1,24 @@
// simplified implementation of <https://github.com/jamielinux/default-zoom>
//
// XXX(2024-12-01): this implementation works for any tabs loaded with ctrl+t, and ctrl+l.
// it works for the homepage too, except for a first-run edge case wherein the homepage is loaded
// before any extensions are loaded
//
let defaultZoom = 2.0;
function setZoom(tabId, changeInfo) {
if (changeInfo.status) {
const gettingZoom = browser.tabs.getZoom(tabId);
gettingZoom.then((currentZoom) => {
if (defaultZoom !== 1 && currentZoom === 1) {
browser.tabs.setZoom(tabId, defaultZoom);
}
});
}
}
browser.tabs.onCreated.addListener((tab) => {
browser.tabs.setZoom(tab.id, defaultZoom);
});
browser.tabs.onUpdated.addListener(setZoom);

View File

@@ -0,0 +1,27 @@
# inlined/simplified version of <https://github.com/jamielinux/default-zoom>
{
stdenvNoCC,
zip,
}:
stdenvNoCC.mkDerivation {
pname = "default-zoom";
version = "0.1";
src = ./.;
nativeBuildInputs = [ zip ];
buildPhase = ''
runHook preBuild
zip -j firefox.zip \
background.html background.js manifest.json
runHook postBuild
'';
installPhase = ''
runHook preInstall
install firefox.zip $out
runHook postInstall
'';
passthru.extid = "@default-zoom";
}

View File

@@ -0,0 +1,17 @@
{
"manifest_version": 2,
"browser_specific_settings": {
"gecko": {
"id": "@default-zoom"
}
},
"name": "Default zoom",
"description": "statically configure a default zoom value for new tabs",
"version": "0.1.0",
"background": {
"scripts": [
"background.js"
]
},
"permissions": []
}

View File

@@ -119,6 +119,7 @@ let
browserpass-extension = callPackage ./browserpass-extension { };
bypass-paywalls-clean = callPackage ./bypass-paywalls-clean { };
ctrl-shift-c-should-copy = callPackage ./ctrl-shift-c-should-copy { };
default-zoom = callPackage ./default-zoom { };
firefox-xdg-open = callPackage ./firefox-xdg-open { };
i-still-dont-care-about-cookies = callPackage ./i-still-dont-care-about-cookies { };
# open-in-mpv = callPackage ./open-in-mpv { };