Advertisement
RosemaryOrchard

Process Inbox Tasks (OmniFocus)

Aug 20th, 2020 (edited)
4,044
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*{
  2.     "author": "Rosemary Orchard",
  3.     "targets": ["omnifocus"],
  4.     "type": "action",
  5.     "identifier": "com.rosemaryorchard.process-inbox-tasks",
  6.     "version": "0.1",
  7.     "description": "A plug-in to help me automatically process tasks in my inbox by adding tags and replacing text.",
  8.     "label": "Process Inbox Tasks",
  9.     "mediumLabel": "Process Inbox Tasks",
  10.     "paletteLabel": "Process Inbox Tasks",
  11. }*/
  12. (() => {
  13.     var action = new PlugIn.Action(function(selection, sender){
  14.         document.windows[0].perspective = Perspective.BuiltIn.Inbox
  15.         inbox.forEach(function(task){
  16.             if (task.name.startsWith('--')) {
  17.                 let newTask = Task.byParsingTransportText(task.name);
  18.                 newTask.note = task.note;
  19.                 deleteObject(task);
  20.             } else if (task.name.includes(" - IKEA") && task.note.includes("https://www.ikea.com")) {
  21.                 let ikeaTag = tagsMatching('Ikea')[0];
  22.                 task.name = task.name.replace(" - IKEA", "");
  23.                 task.addTag(ikeaTag);
  24.             } else if (task.name.includes(" | Wilko") && task.note.includes("https://www.wilko.com")) {
  25.                 let wilkoTag = tagsMatching('Wilko')[0];
  26.                 task.name = task.name.replace(" | Wilko", "").replace("Wilko", "").trim();
  27.                 task.addTag(wilkoTag);
  28.             } else if (task.name.includes(" | Argos") && task.note.includes("https://www.argos.co.uk")) {
  29.                 let wilkoTag = tagsMatching('Argos')[0];
  30.                 task.name = task.name.replace(" | Argos", "");
  31.                 task.addTag(wilkoTag);
  32.             } else if (task.name.includes(" - B&M") && task.note.includes("https://www.bmstores.co.uk")) {
  33.                 let wilkoTag = tagsMatching('B&M')[0];
  34.                 task.name = task.name.replace(" - B&M", "");
  35.                 task.addTag(wilkoTag);
  36.             } else if (task.name.includes(" | Morrisons") && task.note.includes("morrisons.com")) {
  37.                 let supermarketTag = tagsMatching('🛒 Supermarket')[0];
  38.                 let morrisonsTag = tagsMatching("Morrisons")[0];
  39.                 task.name = task.name.replace(" | Morrisons", "");
  40.                 task.addTag(supermarketTag);
  41.                 task.addTag(morrisonsTag);
  42.             }
  43.             task.name = task.name.replace("  ", " ").trim(); //replace any double spaces left, and remove any spaces before or after the text
  44.         })
  45.     });
  46.  
  47.     action.validate = function(selection, sender){
  48.         return (inbox.length > 0)
  49.     };
  50.        
  51.     return action;
  52. })();
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement