Interacting with Web Browsers via Automation Tasks
Alfred's Automation Tasks have been able to interact with web browsers since their first release. They allow you to effortlessly get a list of open tabs, create new windows, interact with tabs matching a certain pattern, run JavaScript, and more.
Because different browsers require different commands for certain operations, until now, you needed to specify which browser to run an action on. While that's fine for your own workflows if you only use one browser, it requires extra steps if you wish to support multiple browsers at once.
This is why, in the 2023.3
release of Automation Tasks, we introduced the Frontmost Browser collection. It supports every Task from the other groups and adapts its behaviour to the browser which is the frontmost app.
While the previous tasks maintain their relevance because they can target specific browsers in multiple contexts, often you just want to run something on whatever browser you're working in at the moment. With the new Tasks, that becomes significantly easier.
This update also includes support for two new browsers: full support for Orion and initial support for Arc.
A few caveats apply: because Webkit browsers (Safari, Orion) do not have AppleScript hooks to open Private Windows, that functionality is disabled for them. In that same vein, Arc's AppleScript support is limited (e.g. cannot get tabs from a single window) and strays from other Chromium browsers, so current support is restricted to tasks which interact with the frontmost tab. We will continue to adapt the Automation Tasks as browsers evolve their AppleScript functionality.
Error handling has also gotten a lift: every browser Automation Task checks early if it can act on a particular browser and will show an error on the debugger if it cannot, together with an exhaustive list of every browser which supports the action.
Finally, this update brings with it general code improvements and other new tasks, including one to change the URL of the current tab and ways to strip leading and trailing arguments and lines of text.