Description
I find the program described in "Save Your Safari URLs into Evernote!" very useful and wanted another that does the reverse. I could not find such a script so apologies if it already exists. I borrowed some code from here to open the list. To use, select one or more Evernote notes and run the script. Each note opens a new Safari window with individual links opened in their own tabs. I am not an Applescript expert, so it may not be very robust.The Code
tell application "Evernote"
set noteList to selection
repeat with SelNote in noteList
set notetxt to the HTML content of SelNote
set urlList to {}
repeat -- scan for links in HTML
set P1 to (offset of "<a href=" in notetxt) + 9 -- the beginning of the link
if P1 is equal to 9 then exit repeat
set notetxt to text P1 through -1 of notetxt
set P2 to (offset of ">" in notetxt) - 2 -- the end of the link
set anURL to text 1 through P2 of notetxt
set urlList to urlList & {text 1 through P2 of notetxt}
end repeat
my openURLs(urlList)
end repeat
end tell
on openURLs(urlList)
set numURLs to (count urlList)
if numURLs > 0 then
tell application "Safari"
activate
my newWIndow()
set the URL of document 1 to (item 1 of urlList)
repeat with i from 2 to (numURLs)
my newTab()
set the URL of document 1 to (item i of urlList)
end repeat
end tell
end if
end openURLs
on newWIndow()
tell application "System Events"
tell process "Safari"
click menu item "New Window" of menu "File" of menu bar 1
end tell
end tell
end newWIndow
on newTab()
tell application "System Events"
tell process "Safari"
click menu item "New Tab" of menu "File" of menu bar 1
end tell
end tell
end newTab
set noteList to selection
repeat with SelNote in noteList
set notetxt to the HTML content of SelNote
set urlList to {}
repeat -- scan for links in HTML
set P1 to (offset of "<a href=" in notetxt) + 9 -- the beginning of the link
if P1 is equal to 9 then exit repeat
set notetxt to text P1 through -1 of notetxt
set P2 to (offset of ">" in notetxt) - 2 -- the end of the link
set anURL to text 1 through P2 of notetxt
set urlList to urlList & {text 1 through P2 of notetxt}
end repeat
my openURLs(urlList)
end repeat
end tell
on openURLs(urlList)
set numURLs to (count urlList)
if numURLs > 0 then
tell application "Safari"
activate
my newWIndow()
set the URL of document 1 to (item 1 of urlList)
repeat with i from 2 to (numURLs)
my newTab()
set the URL of document 1 to (item i of urlList)
end repeat
end tell
end if
end openURLs
on newWIndow()
tell application "System Events"
tell process "Safari"
click menu item "New Window" of menu "File" of menu bar 1
end tell
end tell
end newWIndow
on newTab()
tell application "System Events"
tell process "Safari"
click menu item "New Tab" of menu "File" of menu bar 1
end tell
end tell
end newTab