Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Linux
  3. Clean all URLs in clipboard

Clean all URLs in clipboard

Scheduled Pinned Locked Moved Linux
27 Posts 11 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • meekah@lemmy.worldM This user is from outside of this forum
    meekah@lemmy.worldM This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #1

    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 🙂

    tonytins@pawb.socialT E J C U 5 Replies Last reply
    1
    0
    • System shared this topic on
    • meekah@lemmy.worldM [email protected]

      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 🙂

      tonytins@pawb.socialT This user is from outside of this forum
      tonytins@pawb.socialT This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #2

      I wish that option was the default in Firefox.

      F 1 Reply Last reply
      0
      • tonytins@pawb.socialT [email protected]

        I wish that option was the default in Firefox.

        F This user is from outside of this forum
        F This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #3

        It rarely ever does anything in my experience.

        Anyway, I built a URL-cleaning script in AutoHotkey, but that's Windows-only; I, too, am on the hunt for a Linux equivalent. Maybe this could be done in SikuliX or Espanso, via a Python script, but I suck at Python so far.

        C J 2 Replies Last reply
        0
        • meekah@lemmy.worldM [email protected]

          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 🙂

          E This user is from outside of this forum
          E This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #4

          That'd be cool. Whenever I'm sharing a YT link, I'm always a bit suspicious of what info the youtu.be URL is hiding, so I paste it into a browser to get a clean URL.

          Maybe this is silly, but I'd be cool to do that automatically.

          I 1 Reply Last reply
          0
          • meekah@lemmy.worldM [email protected]

            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 🙂

            J This user is from outside of this forum
            J This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #5

            You never define "clean".

            To strip excess URL parameters (i.e. beginning "&", almost certainly junk) if the clipboard buffer contains a URL and only a URL (Wayland only):

            if url=$(printf '%s' "$(wl-paste --no-newline | awk '$1=$1' ORS=' ')" | egrep -o 'https?://[^ ]+') ; then
              wl-copy "${url%%\&*}"
            fi
            
            T meekah@lemmy.worldM E 3 Replies Last reply
            0
            • J [email protected]

              You never define "clean".

              To strip excess URL parameters (i.e. beginning "&", almost certainly junk) if the clipboard buffer contains a URL and only a URL (Wayland only):

              if url=$(printf '%s' "$(wl-paste --no-newline | awk '$1=$1' ORS=' ')" | egrep -o 'https?://[^ ]+') ; then
                wl-copy "${url%%\&*}"
              fi
              
              T This user is from outside of this forum
              T This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #6

              Query parameters are junk? They have tons of legitimate uses, they’re one of the better places to keep state.

              meekah@lemmy.worldM 1 Reply Last reply
              0
              • F [email protected]

                It rarely ever does anything in my experience.

                Anyway, I built a URL-cleaning script in AutoHotkey, but that's Windows-only; I, too, am on the hunt for a Linux equivalent. Maybe this could be done in SikuliX or Espanso, via a Python script, but I suck at Python so far.

                C This user is from outside of this forum
                C This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #7

                It's never worked for me either. The ClearURLs addon has a function to copy a clean URL and that works great though. It's open source, so maybe someone could turn its cleaning function into a program that could be used for the clipboard.

                F 1 Reply Last reply
                0
                • J [email protected]

                  You never define "clean".

                  To strip excess URL parameters (i.e. beginning "&", almost certainly junk) if the clipboard buffer contains a URL and only a URL (Wayland only):

                  if url=$(printf '%s' "$(wl-paste --no-newline | awk '$1=$1' ORS=' ')" | egrep -o 'https?://[^ ]+') ; then
                    wl-copy "${url%%\&*}"
                  fi
                  
                  meekah@lemmy.worldM This user is from outside of this forum
                  meekah@lemmy.worldM This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #8

                  Fair enough, I haven't given that too much thought myself until now. After playing around with Firefox's URL cleaning, I realized there are some parameters I want to keep. So, by clean I mean removing all unnecessary parameters in the URL.

                  For example, https://youtu.be/jNQXAC9IVRw?si=someTrackingId would become https://youtu.be/jNQXAC9IVRw, but https://www.youtube.com/watch?v=jNQXAC9IVRw keeps it's parameter, because it is necessary.

                  I guess replicating the logic for deciding which parameters to keep is not trivial, so the easiest solution is probably just manually pasting links into firefox, and just copying them cleanly from there. Thanks for providing some code, though!

                  I 1 Reply Last reply
                  0
                  • J [email protected]

                    You never define "clean".

                    To strip excess URL parameters (i.e. beginning "&", almost certainly junk) if the clipboard buffer contains a URL and only a URL (Wayland only):

                    if url=$(printf '%s' "$(wl-paste --no-newline | awk '$1=$1' ORS=' ')" | egrep -o 'https?://[^ ]+') ; then
                      wl-copy "${url%%\&*}"
                    fi
                    
                    E This user is from outside of this forum
                    E This user is from outside of this forum
                    [email protected]
                    wrote on last edited by
                    #9

                    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.

                    J 1 Reply Last reply
                    0
                    • C [email protected]

                      It's never worked for me either. The ClearURLs addon has a function to copy a clean URL and that works great though. It's open source, so maybe someone could turn its cleaning function into a program that could be used for the clipboard.

                      F This user is from outside of this forum
                      F This user is from outside of this forum
                      [email protected]
                      wrote on last edited by
                      #10

                      Hmm. Thanks, though I'm seeking universal /offline so if I get URLs in other platforms, I won't have to turn to the browser to purge them of junk. Or maybe this could be converted into a standalone program...

                      1 Reply Last reply
                      0
                      • meekah@lemmy.worldM [email protected]

                        Fair enough, I haven't given that too much thought myself until now. After playing around with Firefox's URL cleaning, I realized there are some parameters I want to keep. So, by clean I mean removing all unnecessary parameters in the URL.

                        For example, https://youtu.be/jNQXAC9IVRw?si=someTrackingId would become https://youtu.be/jNQXAC9IVRw, but https://www.youtube.com/watch?v=jNQXAC9IVRw keeps it's parameter, because it is necessary.

                        I guess replicating the logic for deciding which parameters to keep is not trivial, so the easiest solution is probably just manually pasting links into firefox, and just copying them cleanly from there. Thanks for providing some code, though!

                        I This user is from outside of this forum
                        I This user is from outside of this forum
                        [email protected]
                        wrote on last edited by
                        #11

                        There is no logic as to which parameters is useful and which is used for tracking. But there are databases.

                        Here is the one for the CleanURLs extension and here is the one for the AdGuard URL Tracking filter list (which I recommend everyone should enable in uBlock Origin).

                        meekah@lemmy.worldM 1 Reply Last reply
                        0
                        • I [email protected]

                          There is no logic as to which parameters is useful and which is used for tracking. But there are databases.

                          Here is the one for the CleanURLs extension and here is the one for the AdGuard URL Tracking filter list (which I recommend everyone should enable in uBlock Origin).

                          meekah@lemmy.worldM This user is from outside of this forum
                          meekah@lemmy.worldM This user is from outside of this forum
                          [email protected]
                          wrote on last edited by
                          #12

                          Oh, nice! That's definitely valuable info. Personally, I do think it's too much work to implement that properly, though.

                          I 1 Reply Last reply
                          0
                          • E [email protected]

                            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.

                            J This user is from outside of this forum
                            J This user is from outside of this forum
                            [email protected]
                            wrote on last edited by
                            #13

                            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.

                            I 1 Reply Last reply
                            0
                            • E [email protected]

                              That'd be cool. Whenever I'm sharing a YT link, I'm always a bit suspicious of what info the youtu.be URL is hiding, so I paste it into a browser to get a clean URL.

                              Maybe this is silly, but I'd be cool to do that automatically.

                              I This user is from outside of this forum
                              I This user is from outside of this forum
                              [email protected]
                              wrote on last edited by
                              #14

                              Well for youtube it's quite easy, there are only 4 useful parameters that I can think of, the video id v, the playlist id list and index if it's a playlist and the time t if you're sending a specific time in the video. Everything else can be removed.
                              Here's what uBlock Origin with the AdGuard URL Tracking filter list:

                              ! Youtube
                              $removeparam=embeds_referring_euri,domain=youtubekids.com|youtube-nocookie.com|youtube.com
                              $removeparam=embeds_referring_origin,domain=youtubekids.com|youtube-nocookie.com|youtube.com
                              $removeparam=source_ve_path,domain=youtubekids.com|youtube-nocookie.com|youtube.com
                              ||youtube.com^$removeparam=pp
                              
                              1 Reply Last reply
                              0
                              • J [email protected]

                                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.

                                I This user is from outside of this forum
                                I This user is from outside of this forum
                                [email protected]
                                wrote on last edited by
                                #15

                                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.

                                J 1 Reply Last reply
                                0
                                • meekah@lemmy.worldM [email protected]

                                  Oh, nice! That's definitely valuable info. Personally, I do think it's too much work to implement that properly, though.

                                  I This user is from outside of this forum
                                  I This user is from outside of this forum
                                  [email protected]
                                  wrote on last edited by
                                  #16

                                  There are some examples of projects that use CleanURLs db in its readme but most have not been updated for a long time.

                                  1 Reply Last reply
                                  0
                                  • I [email protected]

                                    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.

                                    J This user is from outside of this forum
                                    J This user is from outside of this forum
                                    [email protected]
                                    wrote on last edited by
                                    #17

                                    Search results, sure. Personally I have rarely if ever wanted to save or share such URLs. But sure.

                                    1 Reply Last reply
                                    0
                                    • meekah@lemmy.worldM [email protected]

                                      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 🙂

                                      C This user is from outside of this forum
                                      C This user is from outside of this forum
                                      [email protected]
                                      wrote on last edited by
                                      #18

                                      The problem is, how do you distinguish url parameters that are essential from url parameters thats used to track?

                                      1 Reply Last reply
                                      0
                                      • T [email protected]

                                        Query parameters are junk? They have tons of legitimate uses, they’re one of the better places to keep state.

                                        meekah@lemmy.worldM This user is from outside of this forum
                                        meekah@lemmy.worldM This user is from outside of this forum
                                        [email protected]
                                        wrote on last edited by
                                        #19

                                        As a WebDev... URL parameters are definitely not the place to keep state... Were not in the 00's anymore. They do have legit uses, but we have JS localStorage nowadays.

                                        T 1 Reply Last reply
                                        0
                                        • F [email protected]

                                          It rarely ever does anything in my experience.

                                          Anyway, I built a URL-cleaning script in AutoHotkey, but that's Windows-only; I, too, am on the hunt for a Linux equivalent. Maybe this could be done in SikuliX or Espanso, via a Python script, but I suck at Python so far.

                                          J This user is from outside of this forum
                                          J This user is from outside of this forum
                                          [email protected]
                                          wrote on last edited by
                                          #20

                                          Alternatively you can configure a hotkey in the GNOME Settings, or the equivalent for other DEs, to execute a bash script or anything.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups