Last active
February 20, 2021 04:24
-
-
Save yb66/d39109df620ab1db2a46c943111c31d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Because I don't like being tracked by Facebook around the web | |
# This function, which I load via my ~/.zshrc, | |
# - takes the url on the clipboard (when run) | |
# - decodes the querystring to find the original link | |
# - removes the FB id from the resulting query string | |
# - pops it back onto the clipboard | |
fb-uri(){ | |
str=${1:-`pbpaste`} | |
ruby -W0 -ruri -r'rack/utils' -e "print URI(Rack::Utils.parse_query(URI('$str').query)['u']).then{|uri| %Q(#{uri.scheme}://#{uri.host}#{uri.path}#{ (hs = Rack::Utils.parse_query(uri.query).reject{|k,_| k == 'fbclid'}).empty? ? '' : %Q(?#{Rack::Utils.build_query hs}) }) }" | pbcopy | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment