zen: add redirects to alternative front ends

This commit is contained in:
2026-03-23 08:41:20 -07:00
parent c2720bcb11
commit fcab26f20e
2 changed files with 78 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ let
ublockSettings = import ./ublock.nix { inherit lib; };
darkReaderSettings = import ./dark-reader.nix { inherit lib; };
redirectorSettings = import ./redirector.nix { inherit lib; };
in
{
programs.zen-browser = {
@@ -44,6 +45,7 @@ in
darkreader
fastforwardteam
localcdn
redirector
refined-github
return-youtube-dislikes
search-by-image # reverse image search
@@ -57,6 +59,7 @@ in
settings = {
"uBlock0@raymondhill.net" = ublockSettings;
"addon@darkreader.org" = darkReaderSettings;
"redirector@einaregilsson.com" = redirectorSettings;
};
};

View File

@@ -0,0 +1,75 @@
# Redirector extension settings
# Addon ID: redirector@einaregilsson.com
#
# To add a new redirect, just add another mkRedirect call to the list:
# (mkRedirect { from = "youtube.com"; to = "invidious.example.com"; description = "YouTube to Invidious"; })
{ lib }:
let
# helper to create a redirect rule from a simple domain mapping.
# handles www. subdomains automatically. for other subdomains
# (like old.reddit.com), create a separate rule with the full domain.
mkRedirect =
{
from,
to,
description,
}:
let
escapedFrom = builtins.replaceStrings [ "." ] [ "\\." ] from;
in
{
inherit description;
exampleUrl = "https://${from}/example";
exampleResult = "https://${to}/example";
error = null;
includePattern = "^https?://(www\\.)?${escapedFrom}(.*)$";
excludePattern = "";
patternDesc = "";
redirectUrl = "https://${to}$2";
patternType = "R";
processMatches = "noProcessing";
disabled = false;
grouped = false;
appliesTo = [ "main_frame" ];
};
in
{
force = true;
settings = {
redirects = [
(mkRedirect {
from = "x.com";
to = "xcancel.com";
description = "X to xcancel";
})
(mkRedirect {
from = "twitter.com";
to = "xcancel.com";
description = "Twitter to xcancel";
})
(mkRedirect {
from = "reddit.com";
to = "safereddit.com";
description = "Reddit to Redlib";
})
(mkRedirect {
from = "old.reddit.com";
to = "safereddit.com";
description = "Old Reddit to Redlib";
})
(mkRedirect {
from = "new.reddit.com";
to = "safereddit.com";
description = "New Reddit to Redlib";
})
(mkRedirect {
from = "np.reddit.com";
to = "safereddit.com";
description = "NP Reddit to Redlib";
})
];
disabled = false;
logging = false;
enableNotifications = false;
};
}