pattulus
10/27/2013 - 4:52 PM

Instant list of current Chrome tabs to an OmniFocus inbox task. Based on work by Veritrope and Zettt.

Instant list of current Chrome tabs to an OmniFocus inbox task. Based on work by Veritrope and Zettt.

(*
http://veritrope.com
Google Chrome URLs List to OmniFocus
Version 1.0
April 23, 2011
Project Status, Latest Updates, and Comments Collected at:
http://veritrope.com/code/safari-tab-list-to-omnifocus
=========
BASED ON THIS SAFARI/EVERNOTE SCRIPT:
http://veritrope.com/code/export-all-safari-tabs-to-evernote/

WITH GREAT THANKS TO GORDON WHO SUBMITTED THE OMNIFOCUS MODIFICATION!
=========
Installation: Just double-click on the script!

FastScripts Installation (Optional, but recommended):
--Download and Install FastScripts from http://www.red-sweater.com/fastscripts/index.html
--Copy script or an Alias to ~/Library/Scripts/Applications/Yojimbo
--Set up your keyboard shortcut

CHANGELOG:
1.00    INITIAL RELEASE
1.10    Removed unnecessary code
        don't output double return on last tab
        process frontmost window instead of window 1
        better documentation
        more consistent naming of variables (url_list, TabInfo)
        Changes provided by Zettt http://macosxscreencasts.com

*)

set urlList to {}
set currentTab to 0

-- set OmniFocus date stamp
set the dateStamp to ((the current date) as string)
set noteTitle to "URL List from Chrome Tabs on " & the dateStamp

tell application "Google Chrome"
	
	-- processing frontmost Google Chrome window
	set chromeWindow to first window
	set tabCount to (count of (tabs of chromeWindow))
	
	try
		repeat with t in (tabs of chromeWindow)
			set currentTab to currentTab + 1
			
			set tabTitle to (title of t)
			set tabURL to (URL of t)
			
			if currentTab is not equal to tabCount then
				set tabInfo to (tabTitle & return & tabURL & return & return)
			else
				-- don't output double return on last tab
				set tabInfo to (tabTitle & return & tabURL)
			end if
			
			copy tabInfo to the end of urlList
		end repeat
	end try
end tell

-- to check the output of this script
log urlList as text

tell front document of application "OmniFocus"
	make new inbox task with properties {name:(noteTitle), note:urlList as rich text}
end tell