then it dawned at me that im an idiot ..i should be using 1 macro group with same set of URLs and just open them in the browser i want
now im not sure whats the best strategy to achive this. initially i thought of an if else command where if browser is X open with X, if its Y open in Y..but 1)can one add 3 if else's (i can only see an if and then else option) and 2)that seems repetative?
then i though is there a way to auto get into a variable the application (browser) that is in front, ie the one im actually using and then use that with the open with option in the open url command?
You don't need to get the name of the application/browser that is in front because you can do it this way:
There are many KM actions which require hardcoded application names. None of these allow "variables" for the application name. However AppleScript probably has ways to do that sort of thing, so it may be possible to use AppleScript to handle applications by name in a variable.
ahh this is neat but i currently use firefox and this seems to only work with safari/chrome, is that correct or am i missing something (i did try it and it didnt work in ff but rather opens the url in chrome-currenty default on my system)
also: as opposed to the open url which opens the URL in a new tab here it seems to open in the same tab?
Of course, you would need an IF statement for each browser that you use. That's not too difficult. The IF statements don't have to be nested; they can be sequential.
ok problem solved , for those in the future that may be interested i had to use the full url , ie http://XXX.. previously in my macros that wasnt necessary...
It'll work even better if you use https:// wherever possible. Yes, modern browsers should renegotiate the http connection to https -- but why wait for that?
This is because Firefox doesn't have any AppleScript-ability -- so most of KM's browser actions won't work with it.
Re. the "won't work in Firefox" comment, this may help you.
I had a similar challenge. However, I didn't need to open a bunch of URLs, but when you look at my Javascript code snippet below you'll see that it can easily be modified to open whatever URL(s) you want. In my case, I want to reload a google search results page with the old 100 results instead of the new limit of 10 per page loaded. Apparently google has changed what and how they return search results (a real bummer, I think). This snippet runs in an action titled, "Execute JavaScript in Front Browser."
I think all you'd have to do is execute this single line of code however many times you want:
window.location.href = URL;
ORIGINAL CODE SNIPPET WITH THE REGEX REPLACE.
let url = window.location.href;
let regex = /num=\d+/;
The problem is that the "Execute JavaScript in Front Browser" requires the browser supports AppleScript to at least the do javascript (WebKit) or execute (Chromium) -- which Firefox doesn't.
Indeed, if you open Safari or Chrome, make Firefox your frontmost browser, then run this action:
...Firefox is completely ignored and Safari or Chrome pops to the front to handle it.
..Firefox is completely ignored and Safari or Chrome pops to the front to handle it.
i can confirm that
would be great to get alternative support in Keyboard Maestro for FF (even though it dosent support applescript :)). in 2025 extensions are kinda going away in chrome (aAt least the good ones) and in general its always good to support the smaller players
been using safari for like 8 years but after using chrome (and then FF) lately damm been missing out on some life changing privacy and ad blocking (for the bad ads...) extensions that are great
PS. is there another non applescript way of getting the URL/Title of the current tab in FF (js? magic? :))
Other way round -- you need to press Mozilla to include the relevant hooks in Mac Firefox. Good luck with that -- they've ignored any such requests since day 1...
On a slightly more optimistic note, if they want Firefox to take advantage of Apple Intelligence they'll have to include various "Intents". And you should be able to leverage those Intents through Shortcuts and, therefore, KM. Don't hold your breath waiting for that to happen, though!
For the URL, same was you would do it manually -- make the window active, "Send a Keystroke... โL" to activate the address bar, "Send a Keystroke... โC" to copy the URL. You can open an URL in the same way, but pasting with โV.
For the title, you could macro the UI to show Firefox's Developer Tools, switch to Console, enter your JavaScript code, somehow get the result returned. But, most of the time, the %FrontWindowName% token is a good enough proxy for the actual page title.