Twitter

Website URL

Jabber

Location

Interests

I’ve been seeing a lot of workflows that need to interact with a browser via AppleScript (usually to get a page’s url), but most of them seem to settle on a single browser (usually Safari), which is a shame. I can certainly understand — applescript is a pain, and since each browser implements this functions however they want, finding the best way to do it with each one can be difficult, so here’s the code for some of them.
The code for this might seem massive, but is actually short. Read the comments to understand when to use what.
You can find the latest version of this as a gist.
-- AppleScript --
-- This example is meant as a simple starting point to show how to get the information in the simplest available way.
-- Keep in mind that when asking for a `return` after another, only the first one will be output.
-- This method is as good as its JXA counterpart.
-- Google Chrome
tell application "Google Chrome" to return title of active tab of front window
tell application "Google Chrome" to return URL of active tab of front window
-- Google Chrome Canary
tell application "Google Chrome Canary" to return title of active tab of front window
tell application "Google Chrome Canary" to return URL of active tab of front window
-- Chromium
tell application "Chromium" to return title of active tab of front window
tell application "Chromium" to return URL of active tab of front window
-- Opera
tell application "Opera" to return title of active tab of front window
tell application "Opera" to return URL of active tab of front window
-- Vivaldi
tell application "Vivaldi" to return title of active tab of front window
tell application "Vivaldi" to return URL of active tab of front window
-- Safari
tell application "Safari" to return name of front document
tell application "Safari" to return URL of front document
-- Safari Technology Preview
tell application "Safari Technology Preview" to return name of front document
tell application "Safari Technology Preview" to return URL of front document
-- Webkit
tell application "Webkit" to return name of front document
tell application "Webkit" to return URL of front document
-- This example will return both the title and URL for the frontmost tab of the active browser, separated by a newline.
-- Keep in mind that to be able to use a variable in `tell application` — via `using terms from` — we’re basically requiring that referenced browser to be available on the system.
-- That means that to use this on "Google Chrome Canary" or "Chromium", "Google Chrome" needs to be installed. Same for other browsers.
-- This method also does not exit with a non-zero exit status when the frontmost application is not a supported browser.
-- For the aforementioned reasons, this method is inferior to its JXA counterpart.
tell application "System Events" to set frontApp to name of first process whose frontmost is true
if (frontApp = "Google Chrome") or (frontApp = "Google Chrome Canary") or (frontApp = "Chromium") or (frontApp = "Opera") or (frontApp = "Vivaldi") then
using terms from application "Google Chrome"
tell application frontApp to set currentTabTitle to title of active tab of front window
tell application frontApp to set currentTabUrl to URL of active tab of front window
end using terms from
else if (frontApp = "Safari") or (frontApp = "Safari Technology Preview") or (frontApp = "Webkit") then
using terms from application "Safari"
tell application frontApp to set currentTabTitle to name of front document
tell application frontApp to set currentTabUrl to URL of front document
end using terms from
else
return "You need a supported browser as your frontmost app"
end if
return currentTabUrl & "\n" & currentTabTitle
// JavaScript for Automation (JXA) //
// This example is meant as a simple starting point to show how to get the information in the simplest available way.
// Keep in mind that when asking for a value after another, only the last one one will be output.
// This method is as good as its AppleScript counterpart.
// Google Chrome
Application('Google Chrome').windows[0].activeTab.name()
Application('Google Chrome').windows[0].activeTab.url()
// Google Chrome Canary
Application('Google Chrome Canary').windows[0].activeTab.name()
Application('Google Chrome Canary').windows[0].activeTab.url()
// Chromium
Application('Chromium').windows[0].activeTab.name()
Application('Chromium').windows[0].activeTab.url()
// Opera
Application('Opera').windows[0].activeTab.name()
Application('Opera').windows[0].activeTab.url()
// Vivaldi
Application('Vivaldi').windows[0].activeTab.name()
Application('Vivaldi').windows[0].activeTab.url()
// Safari
Application('Safari').documents[0].name()
Application('Safari').documents[0].url()
// Safari Technology Preview
Application('Safari Technology Preview').documents[0].name()
Application('Safari Technology Preview').documents[0].url()
// Webkit
Application('Webkit').documents[0].name()
Application('Webkit').documents[0].url()
// This example will return both the title and URL for the frontmost tab of the active browser, separated by a newline.
// This method is superior to its AppleScript counterpart. It does not need a "main" browser available on the system to reuse the command on similar ones and throws a proper error code on failure.
const frontmost_app_name = Application('System Events').applicationProcesses.where({ frontmost: true }).name()[0]
const frontmost_app = Application(frontmost_app_name)
if (['Google Chrome','Google Chrome Canary','Chromium','Opera','Vivaldi'].indexOf(frontmost_app_name) > -1) {
var current_tab_title = frontmost_app.windows[0].activeTab.name()
var current_tab_url = frontmost_app.windows[0].activeTab.url()
} else if (['Safari','Safari Technology Preview','Webkit'].indexOf(frontmost_app_name) > -1) {
var current_tab_title = frontmost_app.documents[0].name()
var current_tab_url = frontmost_app.documents[0].url()
} else {
throw new Error('You need a supported browser as your frontmost app')
}
console.log(current_tab_url + '\n' + current_tab_title)
Other browsers Camino
Used to be present (see revisions) but the browser itself was discontinued. Firefox
Absent since although it’s possible to get the window’s title, it’s not possible to get its URL (it used to be, before version 3.6). It’s possible via hacky ways that consist of sending keystrokes, but those can be unreliable. This bug is being tracked in Bugzilla.

I want to create a workflow that would open a few urls as pinned tab in my default browsers.
I have tried with one url and it seems there is no option to do it.
Workflow's file is accessible here : https://www.dropbox.com/s/geruuw94ac1ow1g/Open_As_Pinned_Tab.alfredworkflow?dl=0
Thank you.

Hey, sorry if this is the wrong place. I'm new to the forum. Basically, Alfred 3 just randomly started to not opening the proper chrome pages when I do a google search using the bar. The same applies to bookmarks. What I mean is that I'll type something like this:
When I hit enter, Chrome opens, but nothing happens.

Hi!
I felt a little hesitate to start my first topic, because I think my question is quite simple but I couldn't find the answer yet in the forums. But since this is the reason I started using Alfred, I might just ask the community
On my Mac, I use different email applications and browsers to seperate work and private. I use Outlook and Firefox for work and Airmail and Chrome for my private stuff. Now, Chrome is my default browser. What I want to achieve is that all links that I click on in Outlook are opened in Firefox. Is this possible?
Thanks for helping out!
Cheers,
Daniel

Google Chrome is my default browser. But as Firefox seems to have made some significant speed improvements I thought I could use both as "default browser". As it is not possible, as one can have only one default browser, I was wondering if there was a way I could set one "Open URL" action to open the url in the front browser whether it is Firefox or Google Chrome. As of today, I only can open the URL in the default browser.

This is pretty straightforward feature request.
Since Alfred 3.5 there is an ability to search through your browser bookmarks. It's super nice, except it is only bookmarks. Wouldn't it be awesome to search through entire browser history in addition to bookmarks? This is how pretty much all modern browsers search bars are working, and there is a reason for that, it's really useful and convenient, considerably speeding up the time you need to enter URL.
Right now, I often find myself going back to enter URLs/search in Safari, shy away of using Alfred for this type of functionality, since there are more relevant suggestions when I'm using Safari.

I'm trying to figure out if there is a way to configure Alfred to open non-specific URLs, using a partial or whole domain, in a specific browser using a wildcard or contains function. For example: I have a bunch of bookmarks to SharePoint URLs that I need to open in my Windows VM, but most other links I want to continue opening in Safari. The logic I'm looking for is something like "IF URL contains sharepoint.com, then open in Chrome in Windows".
This would allow us to configure one Workflow for each domain (or one to rule if we could do multiple domains in one flow) rather than create a different Workflow for each Open URL action. I set up the many of the single Open URL Workflows previously and somehow Alfred got totally reset the other day - I lost all my settings and preferences - and now I have to rebuild everything again.

I have an Alfred workflow based on a JXA script. It acts as a control mechanism for focusatwill.com (an online music streaming service). It has basic functionality, play/pause, skip track...
This was working fine in an earlier version, interacting with the page using query selectors, e.g.
tab.execute({ javascript: "document.querySelector('.playerControls .playButton').click();" })
This site recently refactored their UI to use React. My basic controls still work (using querySelector), but one part of the setup (changing the genre) has broken. It used to use querySelectorAll for this task, but in the new React UI, the controls I need to reach don't exist unless you click in the UI ...
In any case, the developers exposed an API in the site code, so I can do stuff like
window.faw.play()
window.faw.skip()
window.faw.genre(genreId)
And doing that in the developer console in Chrome works fine. But if I try to do the same using tab.execute in JXA (from Alfred), nothing happens.
I'm guessing that I'm running afoul of the security model in Chrome. Does anyone know if what I'm trying to do is even possible (from Alfred/JXA)? Or am I going to have to try to do this as a Chrome extension instead?
If it's helpful, here is the repository:
https://github.com/tangledhelix/focusatwill-in-google-chrome
And there's some discussion between me and someone at focusatwill.com on this commit:
https://github.com/tangledhelix/focusatwill-in-google-chrome/commit/eb339cba143cdbc2593c73869e11bcd70f18042a

This Alfred workflow lets you select any Firefox profiles found in ~/Library/Application\ Support/Firefox/Profiles/. It lets you open different FF profiles in parallel. This workflow is written in Ruby which I never worked with before. I think there are better ways to do it. Anyways, I am using it on a daily base. https://github.com/mikezahno/alfredworkflow-ffp It is not yet on packal as I am new to the community. Any suggestions and contributions are very welcome.

Good evening everybody,
I am looking for directions (a) to find an already existing workflow (that I wasn't able to find) or (b) to allow me to create my own, in regards to the following "problem":
I use Safari as my primary and have Opera installed as my secondary browser. While viewing a website in Safari, I sometimes would like to be able to use an Alfred-keyword to open the same website in Opera and vice-versa.
Any directions?
Thank you!

Hello everyone!
This is my first post and my first shared workflow, but I've gleaned so much through the forum as a lurker, so thanks!
This is a utility for developers who are using Google's Firebase. I was so tired clicking around that I had to created this workflow, which simply opens a browser window directly to the given location in the Firebase Console.
It also has live search thanks to @SamVerschueren's great alfred-firebase workflow, which mine triggers when `Documentation` is selected.
Packal keeps giving me an error upon submitting, so I don't have it there yet. But the screenshots + code are on Github.
Would love any feedback or questions!

I've created a small workflow that automates something that I've find myself doing very often: copying a website as an HTML hyperlink text and pasting it into the footnote of my notes to track my sources.
Simply type copylink or copylinkmd to see a list of open browser tabs (currently for Chrome and Safari only). Then, select one to copy the title of the page linked to the URL.
Download v1.3 | Github
See Github page for release notes.
Hope you'll find it useful. Let me know of any bugs or feedback below.
— Charlie

Hi, I am a designer and for my job I need sometimes to find a bunch of pictures for my design presentation.
I've read several thread regarding this but I think I am still clueless as to how it works. Maybe just need some one to point me to the right direction.
What I am looking for:
I have a small list (10-15 words) with keywords on txt file:
one
two
three
...
ten
And there is one site which I want to open in standard browser (safari) with this list of urls:
https://www.shutterstock.com/search/one
https://www.shutterstock.com/search/two
https://www.shutterstock.com/search/three
...
https://www.shutterstock.com/search/ten
What is the best way to do it?
Any help would be appreciated.

I made this to fit my web development workflow, primarily for responsive testing.
This workflow opens a new resized window of the active tab for small, medium, and large devices in Google Chrome Canary, or Google Chrome.
There's also an options to open two new windows, small and large, side by side, or open a new resized window and open DevTools at the same time.
I've also included the Firechrome Alfred workflow to open Chrome's active tab in FireFox.
Hopefully some of you fellow web developer's will find this useful. Feedback would be much appreciated. Window positioning still needs some work, as well as window positioning when using multiple displays.
Here's a link to the repo:
https://github.com/wad3g/alfred-chrome-canary-webdev

Github: https://github.com/dearrrfish/browser-sugar-alfredworkflow
Packal: http://www.packal.org/workflow/browser-sugar
Screenshots: http://imgur.com/a/gYqc8
Please read README on Github if you are interested.
This workflow helps to:
Switch tab(s) from one browser to another ( currently supports Safari and Chrome )
Copy data from browser tab(s) or application in text
Open URL(s) from text of selection or the clipboard
Stash group of tabs from browser, save for later
Unstash saved group of tabs, into browser
It also provides syntax patterns, allowing user to config default settings for each action, or customize action script and assign hotkeys.
-- NORMAL --

Hi,
Just uploaded two new (old for me) workflows that I find very useful and thought someone else might like them. They are:
Copy/Move To Workflow This workflow starts with a "Add Directory to Copy/Move locations..." File Action to create a list of directories to use as targets for a copy/move operation. If actioned on a file, the directory of the file is saved. Once you have a list, you can use "copy to..." or "move to..." file actions to move or copy files to a previously saved directory. The keyword "cm:fav" is used to view saved directories, remove one, go to one in Alfred Browser, open in Finder, or go to in terminal/iTerm depending on your terminal preset in Alfred.
Alfred Browser Toolbox
Keywords
ff
It is a way to lookup a folding in the Alfred browser or in Finder. Very handy.
ab:newfile
Creates a new file in the directory of the topmost Finder, Commander One, or Path Finder window.
ab:newdir
Creates a new directory in the directory of the topmost Finder, Commander One, or Path Finder window.
ab:open
Opens the URL, URI, or file given using the Mac OS X open terminal command. This has a hot key as well to open the current selection with "open". This works with Finder, Path Finder, and Commander One.
ab:pdf
This is a file filter for PDF files. I have many and this really makes finding them easy.
ab:cparent
This command will get the currently selected file in Finder, Path Finder, or Commander One and copy it to the parent directory. Works on files or directories. This has a Hotkey as well.
ab:mparent
This command will get the currently selected file in Finder, Path Finder, or Commander One and move it to the parent directory. Works on files or directories. This has a Hotkey as well.
ab:cfile
This command will copy the contents of the file to the clipboard. You need to be sure it is a text file. This has a Hotkey as well.
Alfred Browser Actions
Get File Name
This gets the name of the file selected in Alfred Browser and puts it into the clipboard.
Get File Size
This gets the file size of the file selected in the Alfred Browser and puts it into the clipboard.
Create a File
Simply creates a file in the directory this file action is ran on. It will ask you for the name and then create it.
Create a Directory
Same as "Create a File", but creates a directory instead.
Copy Relative Home Path
This file action calculates the relative path from the user’s home directory and copies it to the clipboard.
Paste Relative Home Path
This file action copies the absolute path to the clipboard. It will then paste the relative path to the topmost application.
Copy Absolute Path
This file action copies the absolute path to the clipboard.
Paste Absolute Path
This file action calculates the relative path from the user’s home directory and copies it to the clipboard. It will then paste the relative path to the topmost application.
Copy/Move to Parent Directory
These two actions will copy/move the selected file to the parent directory.
Copy File Contents to Pasteboard
This action will copy the contents of the file to the pasteboard.
NOTE: Currently this requires OS X 10.10 because I am using JavaScript for Automation that is only in 10.10. Sorry!
Version: 1.5
Date: 12/04/2015
You can get them from my Github account: https://github.com/raguay/MyAlfred
or Packal:
http://www.packal.org/workflow/copymove
http://www.packal.org/workflow/alfred-browser-toolbox

It would be good to have some support for Kiwix. Kiwix is an offline reader for web content, most notably Wikipedia.
Here's what I suggest:
By typing in the keyboard wiki, and then following it with some text, it will preview the associated Wikipedia artice.
Pressing enter will open the article in Kiwix.
http://s28.postimg.org/4b8kcllmj/2016_02_18_at_21_27_13.png
http://www.kiwix.org/wiki/Main_Page

I would like to build a workflow that will take a URL (or more than one) and some text, run the 'find' (⌘-f) function to search the site for that text and return the URL in a new tab if text is found.
Example:
URL: http://ontap.me/thefriendlyspot
TEXT: IMPERIAL
If there is an 'IMPERIAL' beer on the list, I would see the URL loaded in a new browser tab and the first instance of 'IMPERIAL' would be highlighted! If not I would get a "Sorry, 'IMPERIAL' not found" growl or notification or some such.
This could have many different uses, but I want to know if the bars near me have what I want to drink without having to hit all of their sites... It also might be nice to know if a movie is available somewhere or something, but my beer needs come first!

Hey guys !
Let me explain the situation first : I work with people on windows but i work on OSX. I often get DOS path on a shared volumes (mounted with samba) where documents i need are stored. Usually, it's .png or other graphic files.
And there we are, i want to do a workflow where i type a keyword then paste the DOS path i was given; then i run a bash script that translate the DOS path to Unix path (script i already have); finally i want that new path to be open in my browser.
So far, i made the input with a "keyword" then the {query} sent to a "Run script" and the new {query} sent to a "Notification". It works that way but it's not what i want.
I can't figure out how to send the new {query} to the browser though.
Did i miss something ?
Thanks for the help
GoOz

First of all, what a great community. Thanks for your help, work and sharing it.
Now I hope there is help for my problem.
Unter Alfred V1 I was using a Applescript and it worked well.
The Script opens Firefox and did a login on a special website.
Now with V2 the script starts but opens 2 firefox windows.
Could anybody please help me and fix the script or build a workflow? Sorry.. I'm a complete newbie.
openFirefoxURL("https://specialwebsite.de/")
on openFirefoxURL(x)
return do shell script "open -a Firefox" & space & quoted form of x
end openFirefoxURL
tell application "System Events"
delay 4
tell application "Firefox"
activate
tell application "System Events" to keystroke "username"
tell application "System Events" to keystroke tab
tell application "System Events" to keystroke "password"
tell application "System Events" to keystroke return
end tell
beep
end tell
Thanks in advance for your help.

Hi everyone,
Very excited by Alfred 2 ! Is there a way to open searches in another browser than safari ? I didn't found any way in the preferences and i'd like to open links in Chrome for example.
Thanks