Created
December 30, 2025 21:25
-
-
Save sillygwailo/4e61b62358447b94c65495cb88402779 to your computer and use it in GitHub Desktop.
Select a random task from the current window in OmniFocus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*{ | |
| "type": "action", | |
| "targets": ["omnifocus"], | |
| "author": "Ethical Detergent", | |
| "identifier": "com.ethicaldetergent.of.randomyTaskFromCurrentWindow", | |
| "version": "1.0", | |
| "description": "Selects a random task from the current window in OmniFocus.", | |
| "label": "Random Task", | |
| "shortLabel": "Random Task", | |
| "paletteLabel": "Random Task", | |
| "image": "" | |
| }*/ | |
| (() => { | |
| const action = new PlugIn.Action(function (selection, sender) { | |
| // From https://omni-automation.com/omnifocus/window.html | |
| var windowContent = document.windows[0].content | |
| var nodes = new Array() | |
| windowContent.rootNode.apply(item => { | |
| if (item.object instanceof Task) { | |
| nodes.push(item) | |
| } | |
| }) | |
| if (nodes.length > 0) { | |
| windowContent.select(nodes) | |
| } | |
| numTasks = document.windows[0].selection.databaseObjects.length | |
| document.windows[0].selection.databaseObjects[Math.floor(Math.random() * numTasks)].url.open() | |
| }) | |
| return action | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment