Skip to content
Sean Akahane-Bryen edited this page Dec 31, 2020 · 3 revisions

Clip highlighted text in Firefox

clip.kmmacros
clip-annotate.kmmacros

Copies the currently selected text in Firefox to a text file, with metadata, optionally with an annotation.

This macro uses a global Keyboard Maestro variable, Last UID, shared with a number of other macros in this repository so that UIDs assigned in rapid succession (more than one in a given clock minute) don't clash.

Keyboard Maestro has more convenient ways of fetching the title and URL of the active page from Safari and Chrome, which would obviate steps 3 to 6 below.

Steps in the Macro

  1. (Prompt the user for a note to be appended to the clipped text.)
  2. Copy the selected text and save it to a variable.
  3. Simulate the keystroke ⌘L to select the active page's URL, then copy and saved it to a variable.
  4. Simulate the keystroke ⌘⌥K to open Firefox's web console. Pause for the console to become active.
  5. Execute the expression copy(document.title) to copy the active page's title, then save it to a variable. (If copy(document.title) appears anywhere in the resulting text file, try lengthening the pause preceding this step.)
  6. Close the developer tools.
  7. Assign a UID, checking for clashes.
  8. Create the text file with the UID as its filename.
  9. Open the text file for the user to check.

Changelog

Version Date Changes
1.02 2020-12-31 Replace YYYY with yyyy in ICU date-time pattern
1.01 2020-07-24 Remove default triggers; use simpler macro names
1.00 2020-07-14 Initial commit
Clone this wiki locally