firefox-extensions.default-zoom: load the zoom from managed storage
this allows it to be configurable per device this changeset probably does *too* much -- a lot can likely be dropped
This commit is contained in:
@@ -69,6 +69,7 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
# uBlock configuration:
|
# uBlock configuration:
|
||||||
|
# TODO: shouldn't this be ~/.mozilla/managed-storage, not ~/.mozilla/firefox/managed-storage?
|
||||||
fs.".mozilla/firefox/managed-storage/uBlock0@raymondhill.net.json".symlink.target = cfg.addons.ublock-origin.package.makeConfig {
|
fs.".mozilla/firefox/managed-storage/uBlock0@raymondhill.net.json".symlink.target = cfg.addons.ublock-origin.package.makeConfig {
|
||||||
# more filter lists are available here:
|
# more filter lists are available here:
|
||||||
# - <https://easylist.to>
|
# - <https://easylist.to>
|
||||||
@@ -96,5 +97,16 @@ in
|
|||||||
# (getUasset "ublock-annoyances-cookies")
|
# (getUasset "ublock-annoyances-cookies")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fs.".mozilla/managed-storage/default-zoom@uninsane.org.json".symlink.text = ''
|
||||||
|
{
|
||||||
|
"name": "default-zoom@uninsane.org",
|
||||||
|
"description": "ignored",
|
||||||
|
"type": "storage",
|
||||||
|
"data": {
|
||||||
|
"zoom": 1.70
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -278,6 +278,7 @@ in
|
|||||||
# redirect librewolf configs to the firefox configs; this way addons don't have to care about the firefox/librewolf distinction.
|
# redirect librewolf configs to the firefox configs; this way addons don't have to care about the firefox/librewolf distinction.
|
||||||
# XXX: this `../` logic assumes `dotDir` is a direct child of ~, and not a path with multiple components!
|
# XXX: this `../` logic assumes `dotDir` is a direct child of ~, and not a path with multiple components!
|
||||||
fs."${cfg.browser.dotDir}/profiles.ini".symlink.target = "../.mozilla/firefox/profiles.ini";
|
fs."${cfg.browser.dotDir}/profiles.ini".symlink.target = "../.mozilla/firefox/profiles.ini";
|
||||||
|
# TODO: shouldn't this be ~/.mozilla/managed-storage, not ~/.mozilla/firefox/managed-storage?
|
||||||
fs."${cfg.browser.dotDir}/managed-storage".symlink.target = "../.mozilla/firefox/managed-storage";
|
fs."${cfg.browser.dotDir}/managed-storage".symlink.target = "../.mozilla/firefox/managed-storage";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
// simplified implementation of <https://github.com/jamielinux/default-zoom>
|
// simplified implementation of <https://github.com/jamielinux/default-zoom>
|
||||||
//
|
|
||||||
|
console.info("[default-zoom]", "background.js: initializing");
|
||||||
|
|
||||||
// XXX(2024-12-01): this implementation works for any tabs loaded with ctrl+t, and ctrl+l.
|
// 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
|
// it works for the homepage too, except for a first-run edge case wherein the homepage is loaded
|
||||||
// before any extensions are loaded
|
// before any extensions are loaded
|
||||||
@@ -10,21 +12,46 @@
|
|||||||
// - desko: youtube.com is most comfortable 1.6 - 1.8
|
// - desko: youtube.com is most comfortable 1.6 - 1.8
|
||||||
// - desko: wikipedia.org is most comfortable 1.7 - 1.9
|
// - desko: wikipedia.org is most comfortable 1.7 - 1.9
|
||||||
// - lappy: amazon.com is most comfortable 1.0 - 1.2
|
// - lappy: amazon.com is most comfortable 1.0 - 1.2
|
||||||
let defaultZoom = 1.7;
|
let defaultZoom = 1;
|
||||||
|
|
||||||
|
// retrieving settings:
|
||||||
|
// - <https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage>
|
||||||
|
// - manifest.json requires `permissions = [ "storage" ]`
|
||||||
|
// - retrieve with `browser.storage.{backend}.get(...)`
|
||||||
|
// - e.g. <https://github.com/mdn/webextensions-examples/blob/main/stored-credentials/storage.js>
|
||||||
|
function applyConfig(storedConfig) {
|
||||||
|
console.info("[default-zoom]", "applyConfig");
|
||||||
|
if (storedConfig && storedConfig.zoom) {
|
||||||
|
console.info("[default-zoom]", "applyConfig -> zoom", storedConfig.zoom);
|
||||||
|
defaultZoom = storedConfig.zoom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onConfigError(error) {
|
||||||
|
console.info("[default-zoom]", "onConfigError");
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
function setZoom(tabId, changeInfo) {
|
function setZoom(tabId, changeInfo) {
|
||||||
|
console.info("[default-zoom]", "setZoom");
|
||||||
if (changeInfo.status) {
|
if (changeInfo.status) {
|
||||||
|
console.info("[default-zoom]", "setZoom -> changeInfo.status exists");
|
||||||
const gettingZoom = browser.tabs.getZoom(tabId);
|
const gettingZoom = browser.tabs.getZoom(tabId);
|
||||||
gettingZoom.then((currentZoom) => {
|
gettingZoom.then((currentZoom) => {
|
||||||
|
console.info("[default-zoom]", "setZoom -> tabs.getZoom complete");
|
||||||
if (defaultZoom !== 1 && currentZoom === 1) {
|
if (defaultZoom !== 1 && currentZoom === 1) {
|
||||||
|
console.info("[default-zoom]", "setZoom -> tabs.setZoom", defaultZoom);
|
||||||
browser.tabs.setZoom(tabId, defaultZoom);
|
browser.tabs.setZoom(tabId, defaultZoom);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
browser.storage.managed.get("zoom").then(applyConfig, onConfigError);
|
||||||
|
|
||||||
|
browser.tabs.onUpdated.addListener(setZoom);
|
||||||
browser.tabs.onCreated.addListener((tab) => {
|
browser.tabs.onCreated.addListener((tab) => {
|
||||||
browser.tabs.setZoom(tab.id, defaultZoom);
|
browser.tabs.setZoom(tab.id, defaultZoom);
|
||||||
});
|
});
|
||||||
|
|
||||||
browser.tabs.onUpdated.addListener(setZoom);
|
console.info("[default-zoom]", "background.js: initialized");
|
||||||
|
@@ -13,7 +13,7 @@ stdenvNoCC.mkDerivation {
|
|||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
zip -j firefox.zip \
|
zip -j firefox.zip \
|
||||||
background.html background.js manifest.json
|
background.html background.js managed_storage.json manifest.json
|
||||||
runHook postBuild
|
runHook postBuild
|
||||||
'';
|
'';
|
||||||
|
|
||||||
@@ -23,5 +23,5 @@ stdenvNoCC.mkDerivation {
|
|||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru.extid = "@default-zoom";
|
passthru.extid = "default-zoom@uninsane.org";
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/draft-03/schema#",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"zoom": {
|
||||||
|
"title": "zoom",
|
||||||
|
"description": "default zoom",
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,17 +1,26 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
|
|
||||||
|
"name": "Default Zoom",
|
||||||
|
"short_name": "Default Zoom",
|
||||||
|
"description": "statically configure a default zoom value for new tabs",
|
||||||
|
"author": "colin@uninsane.org",
|
||||||
|
"version": "0.1.0",
|
||||||
|
|
||||||
"browser_specific_settings": {
|
"browser_specific_settings": {
|
||||||
"gecko": {
|
"gecko": {
|
||||||
"id": "@default-zoom"
|
"id": "default-zoom@uninsane.org",
|
||||||
|
"strict_min_version": "57.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"name": "Default zoom",
|
|
||||||
"description": "statically configure a default zoom value for new tabs",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"background.js"
|
"background.js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"permissions": []
|
"permissions": [
|
||||||
|
"storage",
|
||||||
|
"unlimitedStorage"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user