Run Script action

Over the past several weeks, I’ve been using Drafts to learn JavaScript. To help make this easier, I’ve been using this Run Script action that can quickly evaluate the code and provide feedback.

I’ve incorporated work from a few community members (thanks @jtokash and @draft8) to get to this point and thought I would share it in case others find it useful.

To begin, either select some JavaScript to execute (or the entire draft will be executed if there’s no selection). The action will first prompt you to optionally select an input draft to execute the script on. After execution, any output of the script will be shown in a prompt with the option to save the output as a new draft. Additionally, if an error is encountered, it will also be shown in a prompt with the option to save the error to a new draft.

-Ed

6 Likes

Thank you for sharing this helpful action. Much appreciated.