As far as browser extensions goes, I use CleanURLs[1] on Firefox, and it works as advertised, removing all sorts of crap from URLs before you even need to copy them. It also provides a JSON file with all the rules they use[2], which if you are building a bash script with, you could use to build the parsing logic.
[1] https://addons.mozilla.org/en-US/firefox/addon/clearurls/