Clean unnecessary parameters from URLs copied to clipboard
Go to file
Agatha Lovelace 66228bbefe
Refactor config handling
2024-01-08 21:19:45 +01:00
.github/workflows Include commit hash in CI builds 2023-04-15 14:49:58 +02:00
src Refactor config handling 2024-01-08 21:19:45 +01:00
.envrc Initial commit 2023-04-02 19:20:29 +02:00
.gitignore Allow disabling categories of filters 2023-04-11 19:21:34 +02:00
Cargo.lock Switch to a maintained clipboard library 2024-01-08 17:46:06 +01:00
Cargo.toml Switch to a maintained clipboard library 2024-01-08 17:46:06 +01:00
LICENSE.md Initial commit 2023-04-02 19:20:29 +02:00
README.md Update README.md 2023-05-28 00:07:14 +02:00
default.nix Fix CI 2023-04-02 19:24:33 +02:00
flake.lock Switch to a maintained clipboard library 2024-01-08 17:46:06 +01:00
flake.nix Provide NixOS module 2023-04-15 13:50:30 +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_*"
}
category "Campaign tracking (stm)" disabled=true {
	params "stm_*"
}

Categories are used to structure filter lists and allow disabling/enabling filters in groups. 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";
url-eater.inputs.nixpkgs.follows = "nixpkgs"; #optional
  1. Adding output:
  outputs = inputs@{ self, nixpkgs, url-eater, ... }:
  1. Import NixOS module
imports = [ url-eater.nixosModule ];
  1. Configure the module:
{ ... }: {
  services.url-eater = {
    enable = true;
    filters = ''
      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"
      }
    '';
  };
}

Building from source

Clone this repository, then run:

cargo build --release

You will need Rust 1.65 or newer.
The output binary will be in target/release/url-eater

Alternatively,

nix build github:AgathaSorceress/url-eater