I know firefox has the very useful “Copy clean Link” option in the context menu, but I would like a similar feature for copying links from any other software, like spotify for example. So I am looking for some software that hooks into the clipboard pipeline, and cleans any URL that gets added. I tried googling for something like it, but was completely unsuccessful. Does anyone have a clue how I might go about achieving this?

Thanks in advance :)

Edit: I found out about klipper’s actions, which provide the option to run a command when a string that matches a regex is added to the clipboard buffer. I am not sure how to properly use this though, so any help is appreciated!

  • enkers@sh.itjust.works
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    10 hours ago

    Edit: Oh, OP basically already said the same thing.

    I think it really depends on the website and even where you are on the website. For example, if you’re on YT, the watch?v=<b64_id> is probably not something you want to throw away. If you’re on a news site like imaginarynews.com/.../the-article-title/?tracking-garbage=<...> then you probably do. It’s just a matter of having “sane” defaults that work as most people would expect.

    • JubilantJaguar@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      9 hours ago

      Sure, but my script only gets rid of the second and later parameters, i.e. ones with & not ?. Personally I don’t think I’ve ever seen a single site where an & param is critical. These days there few where the ? matters either, but yes YT is a holdout.

      • ivn@jlai.lu
        link
        fedilink
        English
        arrow-up
        1
        ·
        8 hours ago

        There are plenty of sites that use more than one parameters. It’s true that a lot of sites now use the history API instead of url parameters but you can still find plenty, and you have no garante about the parameters order. Any site with a search page that have a few options will probably use url parameters instead of the history API. It’s easier to parse and will end up being shorter most of the time.