Plug-In: Script URL for Plug-In
This plug-in will place an Omni Automation Script URL for the chosen plug-in action, on the clipboard. The generated script URL can be used in Shortcuts or other 3rd-party applications to externally trigger the execution of targeted the plug-in.
An Automated Shortcuts Workflow
Here’s an example of how to set up the script URL to execute as the result of a Shortcuts Automation triggered workflow.
1 Shortcuts Automation • A Shortcuts Automation workflow actions list.
2 Open URLs Action • A single instance of the Open URLs action from the Safari collection.
3 Script URL • The generated script URL for running the chosen installed Omni Automation plug-in is pasted into the Shortcuts action as the URL value.
4 Script Security Dialog • The first time the script URL is executed, this security dialog will appear.
5 Automatic Approval • Select this switch to allow the indicated script URL to execute without requiring re-approval.
The OmniFocus plug-in shown above is the Just For Today plug-in, which will extract the text contents of a webpage and place that as the value of the notes field of an existing/created task.
Script URL for Plug-In
This plug-in incorporates “follow-on menus” to present a form whose menus update automatically based upon the selection of the first menu.
To use the installed plug-in:
- From the top options menu, select the identifier of the plug-in that you wish to be triggered via the generated Omni Automation script URL.
- From the second options menu, select the name of the plug-in’s action to be executed. NOTE: single-file plug-ins usually only have a single action.
Return to: OmniFocus Plug-In Collection
Script URL for Plug-In
/*{"type": "action","targets": ["omnifocus"],"author": "Otto Automator","identifier": "com.omni-automation.of.of-script-url-for-plug-in","version": "1.1","description": "Places a Script URL for executing the chosen plug-in, on the clipboard.","label": "Script URL for Plug-In","shortLabel": "URL for Plug-In","paletteLabel": "Plug-In URL","image": "link"}*/(() => {const action = new PlugIn.Action(async function(selection, sender){pluginRecords = new Array()PlugIn.all.forEach(plugin => {var pluginRecord = {}pluginRecord.id = plugin.identifierpluginRecord.author = plugin.authorpluginRecord.version = plugin.version.versionStringpluginRecord.description = plugin.descriptionpluginRecord.displayName = plugin.displayNamevar actionRecords = []plugin.actions.forEach(action => {var actionRecord = {}actionRecord.name = action.nameactionRecord.label = action.longLabelactionRecords.push(actionRecord)})pluginRecord.actions = actionRecordspluginRecords.push(pluginRecord)})// console.log(JSON.stringify(pluginRecords))pluginIDs = pluginRecords.map(item => item.id)plugInMenuIndexes = pluginIDs.map((item, index) => index)pluginMenu = new Form.Field.Option("pluginIndex","Plug-In ID",plugInMenuIndexes,pluginIDs,0)pluginMenu.allowsNull = falsepluginActionNames = pluginRecords[0].actions.map(item => item.name)pluginActionIndexes = pluginActionNames.map((item, index) => index)actionMenu = new Form.Field.Option("actionIndex","Action",pluginActionIndexes,pluginActionNames,0)actionMenu.allowsNull = falseform = new Form()form.addField(pluginMenu)form.addField(actionMenu)form.validate = function(formObject){var pluginIndex = formObject.values["pluginIndex"]if (pluginIndex !== currentPluginIndex){currentPluginIndex = pluginIndexform.removeField(form.fields[1])}if (form.fields.length === 1){var pluginActionNames = pluginRecords[pluginIndex].actions.map(item => item.name)var pluginActionIndexes = pluginActionNames.map((item, index) => index)var actionMenu = new Form.Field.Option("actionIndex","Action",pluginActionIndexes,pluginActionNames,0)actionMenu.allowsNull = falseform.addField(actionMenu)}return true}currentPluginIndex = 0formPrompt = "Choose a plug-in:"buttonTitle = "Continue"formObject = await form.show(formPrompt, buttonTitle)pluginIndex = formObject.values["pluginIndex"]pluginRecord = pluginRecords[pluginIndex]pluginID = pluginRecord.idactionIndex = formObject.values["actionIndex"]actionName = pluginRecord.actions[actionIndex].namecodeString = `PlugIn.find("${pluginID}").action("${actionName}").perform()`scriptURLString = "omnifocus://localhost/omnijs-run?script=" + encodeURIComponent(codeString)Pasteboard.general.string = scriptURLStringnew Alert("Script URL Created", "The script URL for the chosen plug-in is on the clipboard.").show()});action.validate = function(selection, sender){return true};return action;})();