Created
February 20, 2011 12:10
-
-
Save atomicules/835932 to your computer and use it in GitHub Desktop.
Pinboard bookmark importer for Camino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Pinboard Bookmark Importer | |
--An Applescript to automate importing of Pinboard.in bookmarks to a collection in Camino. To be used for occasional or one off import | |
-- pinboard username and password | |
property pbuser : "pinboard username" | |
property pbpass : "pinboard password" | |
--Download bookmarks via curl to desktop (because can use shortcut when selecting file for import via UI scripting) | |
do shell script ("cd ~/Desktop; curl https://" & pbuser & ":" & pbpass & "@pinboard.in/export/ -o pinboard.html") | |
--import bookmarks via UI scripting | |
tell application "System Events" | |
if UI elements enabled then | |
tell process "Camino" | |
set frontmost to true | |
end tell | |
click menu item "Import Bookmarks…" of menu of menu bar item "File" of menu bar 1 of process "Camino" | |
click pop up button of window "Import Bookmarks" of process "Camino" | |
click menu item 5 of menu 1 of pop up button of window "Import Bookmarks" of process "Camino" | |
keystroke "D" using {command down} --go to desktop downloads? | |
keystroke "pinboard" --this works as long as there is no other file called "pinboard something or other" on the desktop. | |
keystroke return | |
else | |
tell application "System Preferences" | |
activate | |
set current pane to pane "com.apple.preference.universalaccess" | |
display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\"" | |
end tell | |
end if | |
end tell | |
--delete the previous pinboard folder | |
tell application "Camino" | |
try | |
with timeout of 120 seconds | |
delete bookmark folder "pinboard" | |
end timeout | |
end try | |
end tell | |
--rename the new imported folder | |
tell application "Camino" | |
try | |
set name of bookmark folder "Imported Bookmarks" to "pinboard" | |
end try | |
end tell | |
--delete pinboard file from the desktop | |
tell application "Finder" | |
move file (((path to desktop) & "pinboard.html") as string) to trash | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment