Plug-In: Just For Today

This plug-in uses the fetch() function of the URL class (LINK) to retrieve the contents of the Just For Today website (https://www.jftna.org/jft/) and then sets the note of the inbox task “JFT” to the cleaned content.

DISCLAIMER: Mention of third-party websites and products is for informational purposes only and constitutes neither an endorsement nor a recommendation. OMNI-AUTOMATION.COM assumes no responsibility with regard to the selection, performance or use of information or products found at third-party websites. OMNI-AUTOMATION.COM provides this only as a convenience to our users. OMNI-AUTOMATION.COM has not tested the information found on these sites and makes no representations regarding its accuracy or reliability. There are risks inherent in the use of any information or products found on the Internet, and OMNI-AUTOMATION.COM assumes no responsibility in this regard. Please understand that a third-party site is independent from OMNI-AUTOMATION.COM and that OMNI-AUTOMATION.COM has no control over the content on that website. Please contact the vendor for additional information.

Just For Today
  

/*{ "type": "action", "targets": ["omnifocus"], "author": "Otto Automator", "identifier": "com.omni-automation.of.just-for-today", "version": "1.2", "description": "Retrieves the contents of the Just For Today website (http://www.jftna.org/jft/) and sets the note of the inbox task “JFT” to the cleaned content.", "label": "Just For Today", "shortLabel": "Just For Today", "paletteLabel": "JFT", "image": "doc.append" }*/ (() => { const action = new PlugIn.Action(function(selection, sender){ // Just For Today website url = URL.fromString("http://www.jftna.org/jft/") // retrieve contents of webpage url.fetch(function(data){ // remove HTML tags from text content var strNoTags = data.toString().replace(/(<([^>]+)>)/gi, "") // trim whitespace from paragraphs var paragraphs = strNoTags.split("\n") paragraphs = paragraphs.map(item => {return item.trim()}) // change triple-spaces to double-spaces var str = paragraphs.join("\n") while(str.indexOf("\n\n\n") >= 0) { str = str.replace(/\n\n\n/g, "\n\n") } // replace fixed-space tag with space str = str.replace(/&nbsp;/gi, " ") // locate task, create task if needed var task = inbox.byName("JFT") || new Task("JFT") // set the note to the retrieved text task.note = str // show the task URL.fromString("omnifocus://task/" + task.id.primaryKey).open() }, function(err){ new Alert(err.name, err.message).show() }) }); action.validate = function(selection, sender){return true}; return action; })();