February 11, 2015, 8:25pm
Can anyone help suggest how I might do this with Keyboard Maestro?
I run Feedly as an application using Fluid.app, a lot of the things I’m tracking are done with Google Alerts.
The URLs for these results includes a load of gogle tracking code which I want to strip out before visitng the URL of the result.
Below is a typical example of a Google Alerts URL within which is the actual URL.
The real URL always begins with either http or https and is the second instance in the string of http(s) and it always ends with the first &
So, I’m wondering if a Keyboard Maestro macro could be created that strips out everything before the second instance of http and everything after the first & and then opens the proper URL in Safari?
Could the macro be added to services? That way I could right click on a Google Alerts URL in Feedly that looks of interest, select Services and then the macro from the list.
I’d appreciate any thoughts on how this could be done.
February 11, 2015, 9:15pm
That’s a great little utility Ben, I’ve tested it with several Google Alerts links and it works consistently. Now I need to figure how to incorporate it all into Keyboard Maestro. If nothing else you’ve shown me great way to capture the content I need.
February 11, 2015, 9:30pm
‘&’ is a legitimate character in URLs, so you want to be careful about using it as an end-anchor for your regular expression.
Indeed, Chris. But as I understand it, the '&' belongs to the Google-URL and not the real URL duncmac needs.
Duncmac, this macro should do the trick. You just copy your Google-URL to the clipboard and press Cmd-< (that is the character next to the left Shift-Key on my keyboard).
For adding the macro as a service, you probably have to use Automator, which then fires a trigger. Not sure how to do that.
February 11, 2015, 9:55pm
Thanks for the follow up Ben, I’ll get this set up tomorrow and let you know how it goes.
And thats a good point about the ‘&’ Chris, I’ve not seen an instance of it yet in these Google Alerts results, however I expect I may get the odd one.
February 12, 2015, 1:23pm
Works great thanks Ben. I added ‘Activate Safari’ to the end, so it switches to Safari and shows the result.
There are a lot of things you can add. For example, a routine that checks whether there is a valid URL in the clipboard in the first place, if any. Just play around with some of the other actions KM provides. The regular expression was probably the “hardest” part of your issue to be solved.
February 12, 2015, 6:05pm
Thanks for the ideas Ben, aside from the regex part of which I know nothing, the rest of the macro is pretty straightforward.