Clean unnecessary parameters from URLs copied to clipboard
Go to file
Agatha Lovelace 089835fb86
Add flake usage example
2023-04-03 15:16:35 +02:00
.github/workflows Initial commit 2023-04-02 19:20:29 +02:00
src Initial commit 2023-04-02 19:20:29 +02:00
.envrc Initial commit 2023-04-02 19:20:29 +02:00
.gitignore Initial commit 2023-04-02 19:20:29 +02:00
Cargo.lock Initial commit 2023-04-02 19:20:29 +02:00
Cargo.toml Initial commit 2023-04-02 19:20:29 +02:00
LICENSE.md Initial commit 2023-04-02 19:20:29 +02:00
README.md Add flake usage example 2023-04-03 15:16:35 +02:00
default.nix Fix CI 2023-04-02 19:24:33 +02:00
flake.lock Initial commit 2023-04-02 19:20:29 +02:00
flake.nix Initial commit 2023-04-02 19:20:29 +02:00

README.md

URL Eater

Clean unnecessary parameters from URLs copied to clipboard

Usage

Run with a filter file that specifies which parameters should be removed:

url-eater denylist.kdl

An example filter file:

category "Spotify" {
	params "context@open.spotify.com" "si@open.spotify.com"
}
category "Campaign tracking (itm)" {
	params "itm_*"
}

Categories do not have significance other than to make filter files better structured. Each parameter applies to all URLs, unless a domain like @example.com is specified at the end. Both the parameter and the domain parts can contain wildcards. Use * to match 0 or more characters, and ? to match exactly one character.
The structure is based on NeatURL's format, with a few differences (aside from a different file format):

  • Single character matching (?) is supported.
  • $ and ! rules are currently unsupported.

The intended use case is running the program as a background service.

Example

Before:

https://open.spotify.com/track/0ibuggkWTSDXHo25S0Qqvj?si=e4c675cbaee94c3a

After:

https://open.spotify.com/track/0ibuggkWTSDXHo25S0Qqvj

Usage example

This repository also contains a Nix flake. It can be used in a NixOS configuration like this:

  1. Add flake to inputs:
url-eater.url = "github:AgathaSorceress/url-eater";
  1. Add package
nixpkgs.overlays = [
  (final: prev: {
    url-eater = url-eater.defaultPackage.${final.system};
  })
];
  1. Add a module that defines a systemd service:
{ pkgs, ... }:
let
  filters = pkgs.writeText "filters.kdl" ''
    category "Spotify" {
    	params "context@open.spotify.com" "si@open.spotify.com"
    }
    category "Twitter" {
    	params "cxt@*.twitter.com" "ref_*@*.twitter.com" "s@*.twitter.com" "t@*.twitter.com" "twclid"
    }
  '';
in {
  systemd.user.services."url-eater" = {
    description = "Clipboard URL cleanup service";

    after = [ "graphical-session-pre.target" ];
    wantedBy = [ "graphical-session.target" ];

    script = ''
      exec ${pkgs.url-eater}/bin/url-eater ${filters}
    '';
  };
}