Skip to content

Instantly share code, notes, and snippets.

@sillygwailo
Created December 30, 2025 21:25
Show Gist options
  • Select an option

  • Save sillygwailo/4e61b62358447b94c65495cb88402779 to your computer and use it in GitHub Desktop.

Select an option

Save sillygwailo/4e61b62358447b94c65495cb88402779 to your computer and use it in GitHub Desktop.
Select a random task from the current window in OmniFocus
/*{
"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