Stephen-Lon / Alfred-workflow-save-ur-url

Save a selected URL to a text file (appending if the file exists)
3 stars 1 forks source link

Important note

Version 4.5 (and later) of this workflow requires Alfred 5.5 (and above). It uses Alfred 5.5's Text View action. If you are not using Alfred 5.5 (or later) please install version 4.1 of this workflow.

Introduction

Sometimes when browsing you want to save a URL quickly for future reference without creating a bookmark in your browser. That is what this workflow does. It uses a simple plain text or markdown file (which will be created for you when you first run the workflow if the file doesn't already exist) to which saved URLs will be appended. You select the location folder for that file in the workflow configuration opposite.

Setup

In the workflow configuration choose:

Usage

Saving URLs

Using your Universal Action hotkey on a selected URL, select Save URL to links file from the list and press :

SaveURL

You will then be prompted for a description of the URL (which may be a useful reminder). Type the description (or accept or amend the description if you have checked the configuration for the workflow to attempt to complete the description from the web page title) and press . If you are using a plain text Links file you can leave the description blank by simply pressing . If you are using a markdown Links file you must complete the description:

MDTitlePrompt

The result will be a file which you can open in Alfred's Text View (see below for examples).

Viewing, editing and clearing the Links file

Type the keyword (selected in the workflow configuration) to open the Links file then:

If you choose to view the Links file this is what it looks like in plain text:

ViewPlainLinks

This is what it looks like if you choose to use markdown:

ViewMDLinks

In both cases the prompts at the bottom of the window are the same:

Selecting the option to edit the Links file will:

Searching URLs in a Links file

The search is a case insensitive search for a word which occurs in a saved URLnot for a word in any description of a URL that you have saved. Simply type your search keyword and the relevant URLs will display in Alfred's window. (If you want to display all of your saved URLs type ht.) Press to display the first or any selected URL in your chosen browser (or press Alfred's shortcut key—2, 3, etc.—to display the relevant URL in your chosen browser). Here is an example of a search result:

SearchLinks

You will be warned if:

Configuration options

As mentioned above you can choose (among others):

Warning
There is no error trapping if in the configuration you set the option to view URLs in a Firefox private window when you don't have the Firefox app...but then you wouldn't do that, would you? 😀

Extracting web page titles for description field

Note: Be aware this feature can on occasion, and with some websites, lead to strange results. However if and when it does you can easily overwrite the description field with your own text.

If you check the relevant box in the user configuration the workflow will attempt to extract the title of the web page for which you are saving the URL and put that title in the description field. If the workflow is unable for any reason to retrieve the title the description field will simply be left blank for you to complete.

If you prefer to complete the description field yourself simply leave unchecked the relevant check box.

Acknowledgements

I am indebted to @vitor on the Alfred forum for huge help with the script filter and to @Acidham on the forum for the contribution that enabled extraction of the web page title.