Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for adding task from Google Chrome and Mailplane #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -30,7 +30,9 @@ The `do` command, along with opening the configured workflow document, will also
Use the keywords:
- `do <task>` to create a new task. (Also used to view the document —see above.)
- `domail` to create tasks from emails selected in Apple’s Mail app.
- `domp` to create tasks from emails selected in Mailplane 3 app.
- `dorl` (do 'read later') to create task from Safari page title, URL and highlighted text.
- `doch` (do 'read later from Chrome') to create task from Chrome page title, URL and highlighted text.

Use the modifiers:
- none to append tasks to a project
Expand Down
48 changes: 48 additions & 0 deletions calls.scpt
Expand Up @@ -352,6 +352,28 @@ function getTasksFromMailSelection() {
}


/**
* getTasksFromMailPlane - Create parsable string of tasks from currently
* Selected MailPlane item.
*
* @return {string} Possibly multiline list, suitable for calls to createItemsIn
*/
function getTasksFromMailplane() {

var mp = Application('Mailplane 3')
var url = mp.currenturl()
var name = mp.currenttitle()

var items = []

items.push('- Reply to: "' + name + '"')
items.push('\t\t' + url)

return items.join('\n')

}


/**
* getItemsFromSafari - Create parsable string of task and indented notes from currently
* Selected Mail items.
Expand All @@ -378,6 +400,32 @@ function getItemsFromSafari() {
}


/**
* getItemsFromChrome - Create parsable string of task and indented notes from currently
* active Chrome tab.
*
* @return {string} Possibly multiline list, suitable for calls to createItemsIn
*/
function getItemsFromChrome() {

var chrome = Application('Google Chrome')
var currentTab = chrome.windows[0].activeTab
var url = currentTab.url()
var name = currentTab.name()
var selection = currentTab.execute({javascript:'window.getSelection().toString()'})

var lines = []
lines.push('- Read page: “' + name + '”')
lines.push('\t\t' + url)
if (selection.length > 0 ){
var selectionLines = selection.split('\n')
lines.push('\t\t"' + selectionLines.join('\n\t\t') + '"')
}

return lines.join('\n')
}


/**
* collapseOrExpandAllNotes - set expansion state of all nodes with notes
* * @param {string} desiredState 'Collapsed' or 'Expanded'
Expand Down