COMMENT
Clean up URLs by removing tracking parameters from them. The shortcut supports a built-in list of widely known tracking parameters (courtesy of Robb Knight), and can be easily expanded to remove more tracking parameters from URLs.
COMMENT
Match tracking parameters
TEXT
_bta_c|_bta_tid|_ga|_hsenc|_hsmi|_ke|_openstat|dm_i|ef_id|epik|fbclid|gclid|gclsrc|gdffi|gdfms|gdftrk|hsa_|igshid|matomo_|mc_|mkwid|msclkid|mtm_|ns_|oly_anon_id|oly_enc_id|otc|pcrid|piwik_|pk_|rb_clickid|redirect_log_mongo_id|redirect_mongo_id|ref|s_kwcid|sb_referer_host|soc_src|soc_trk|spm|sr_|srcid|stm_|trk_|utm_|vero_|resize|tpcc

Text
VARIABLES
Set variable
Pattern
to
Pattern
URL
Shortcut Input

URL
VARIABLES
Set variable
Input URL
to
URL
SCRIPTING
If
Input URL
does not have any value
COMMENT
There is no URL from the share sheet
COMMENT
First, check if it is a Mac
SCRIPTING
If
WFInput?
is
Mac
MISSING
runapplescript Under Construction
COMMENT
Check if Safari is running
TEXT
AppleScript Result

Text
SCRIPTING
If
Text
is
Yes
COMMENT
Get the URL from the current Safari tab
MISSING
safari.geturl Under Construction
VARIABLES
Set variable
Input URL
to
URL
SCRIPTING
Otherwise
COMMENT
Safari is not running
SCRIPTING
End If

If Result
SCRIPTING
Otherwise
COMMENT
It is not a Mac; get the URL from the clipboard
WEB
Get URLs from
Clipboard

URLs
VARIABLES
Set variable
Input URL
to
URLs
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
COMMENT
Try one final attempt to see if the Input URL is empty or not; if still empty, just prompt the user to enter one manually.
SCRIPTING
If
Input URL
does not have any value
SCRIPTING
Ask
What’s the URL to clean up?

Provided Input
VARIABLES
Set variable
Input URL
to
Provided Input
SCRIPTING
End If

If Result
DOCUMENTS
Replace
(\?|&)(
Pattern
)\=(.+)
with
World
in
Input URL

Updated Text
WEB
Get URLs from
Updated Text

URLs
SHARING
Copy
URLs
to clipboard
TEXT
Cleaned up and copied:
URLs

Text
NOTIFICATIONS
Show notification
Text
Options Under Construction
COMMENT
Set the output of the shortcut
WEB
Get URLs from
URLs

URLs