Custom Web Searches with results list

I put together a macro that lets you search various sites, see the results in a list, and highlight an item to open its URL. The display is similar to Spotlight or LaunchBar's custom actions.

You switch search types with the tab key, type text to search, navigate results with the arrow keys, select a result with the return key or mouse, and press escape to cancel. It will save your searches and results for 10 minutes.

The download includes a few sample search types. Here's what it looks like:

screen

To install it, first download and unzip this, which contains the HTML/JS/CSS:
customSearch.zip (34.6 KB)

Then create a macro that runs "Custom HTML Prompt", using the path to index.html (in the download) as the file.

You also need to create a second macro, named "Custom Search Open URL". This should run "Open URL", with the value %Variable%CustomSearchURL%. It will be called by name from the search window when you press return.

You can remove search types that you don't use, by editing line 9 in index.html.

You can create your own search types, by writing JS files similar to itunes/index.js, and adding them to line 9 in index.html. They should have a "search" function that returns a promise of an array, in the same format as the examples.

You may also want to insert a "Semaphore Lock" action at the beginning of the macro, to prevent multiple windows from being open at once. Give it a unique name, set the action timeout to 1/100 second, and set it to abort the macro after the timeout.

If you want to use the JIRA or Confluence search types, you'll need to edit the instance, user, and password variables in the scripts. To keep the password secure, you'll need to set a Keyboard Maestro variable called CustomSearchAtlassianPassword with your password. You can store it as a Password entry in your keychain, then use a "Set Keychain Password to Variable" action to set it before opening the Custom HTML Prompt, and then afterwards set the variable to %Delete%. Also, if you type a word in all-caps in the one of these searches, it will restrict the search to that project or space.

3 Likes

This looks great! Would you mind sharing the code to your Jira and Confluence searches for this macro?

Here you go...I updated the download and the instructions. Enjoy!

Awesome, thanks!