Import Some Safari Tabs
Summary: Imports some of the tabs in the frontmost Safari window.
Requires: EagleFiler
Install Location: ~/Library/Scripts/Applications/Safari/
Last Modified: 2019-10-02
Description
This script demonstrates several techniques:
- Importing to a certain library, whether or not it is currently open.
- Asking the user which of the current Safari tabs to import.
- Importing the same URL in two different formats.
- Applying tags to the imported records.
You will need to enter the path to your library in the first line of the script, and your desired tags in the second line.
Installation Instructions · Download in Compiled Format · Download in Text Format
Script
property
_libraryPath : "/Users/mjt/Documents/C-Command/EagleFilerTest/EagleFilerTest.eflibrary"
property
_tagNames : {"sample tag"}
on
run
set
_libraryFile
to
POSIX file
_libraryPath
tell
application
"EagleFiler"
open
_libraryFile
set
_urls
to
my
getURLs()
activate
my
importURLs(
_urls)
end
tell
end
run
on
getURLs()
set
_urlsToImport
to
{}
tell
application
"Safari"
activate
set
_tabs
to
tabs
of
window
1
set
_titles
to
{}
set
_urls
to
{}
repeat
with
_tab
in
_tabs
copy
_tab's
name
to
end
of
_titles
copy
_tab's
URL
to
end
of
_urls
end
repeat
set
_titlesToImport
to
choose from list
_titles
with title
"Import to EagleFiler"
with prompt
"Select the tabs to import:"
default items
_titles
with
multiple selections allowed
repeat
with
_i
from
1
to
count
of
_titles
set
_title
to
item
_i
of
_titles
if
_titlesToImport
contains
_title
then
copy
item
_i
of
_urls
to
end
of
_urlsToImport
end
if
end
repeat
end
tell
return
_urlsToImport
end
getURLs
on
importURLs(
_urls)
tell
application
"EagleFiler"
tell
library document
1
set
_webArchive
to
"Web archive"
set
_bookmark
to
"Bookmark"
set
_both
to
"Web archive and Bookmark"
display dialog
"Import using which formats?"
buttons
{
_webArchive,
_bookmark,
_both}
default button
_both
set
_button
to
button returned
of
the
result
if
{
_webArchive,
_both}
contains
_button
then
import
URLs
_urls
tag names
_tagNames
Web page format
Web archive format
end
if
if
{
_bookmark,
_both}
contains
_button
then
import
URLs
_urls
tag names
_tagNames
Web page format
bookmark format
end
if
end
tell
end
tell
end
importURLs