Hey Folks,
One of the nice things you could do in Lion was kill the Web Process, and you'd regain a lot of memory while Safari kept track of what windows and tabs were open. When you revisited a tab it would load again.
In Mountain Lion if you quit the Web Process Safari also quits.
I recommend the 'Sessions' Safari extension to handle backing up the environment, but sometimes I want to be able to do this manually. It gives me an easy means to quit Safari, regain memory, and reload the formerly active tabs one at a time via another script.
The first script creates name/url pairs for every tab and opens the result in BBEdit ( TextWrangler or another scriptable text editor may be used).
Note: Applescript fails to get the url for any tabs that aren't loaded.
The second script loads the urls from the backup page one at a time in Safari, and it deletes them as it goes. Although it doesn't save the changes, so you can undo in BBEdit if necessary.
-- Chris
------------------------------------------------------------------------------------------------ # Created: 2012-09-22 : 02:05 # Modified: 2012-09-22 : 02:05 # Application: Safari & BBEdit # Purpose: Backup Safari Tab Names & Urls # Dependencies: Only OSX components used. ------------------------------------------------------------------------------------------------
set _list to {}
tell application "Safari" set _bkmks to {name, URL} of tabs of (every window where its document is not missing value) end tell
set AppleScript's text item delimiters to linefeed set _bkmks to _bkmks as text set _bkmks to paragraphs of _bkmks set _div to (length of _bkmks) / 2 as integer set _names to items 1 thru _div of _bkmks set _urls to items (_div + 1) thru -1 of _bkmks
repeat with i from 1 to _div set end of _list to (item i of _names) & tab & "•" & tab & (item i of _urls) end repeat
set _list to _list as text set _list to do shell script "sort -u <<< " & quoted form of _list
tell application "BBEdit" activate set newDoc to make new document with properties {text:_list} end tell
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------ # Author: ccs # Created: 2012-09-22 : 02:49 # Modified: 2012-09-22 : 02:49 # Application: Safari & BBEdit # Purpose: Load urls from backup in Safari one at a time. # Dependencies: Only OSX components used. ------------------------------------------------------------------------------------------------
tell application "BBEdit" set AppleScript's text item delimiters to tab set _doc to item 1 of (text windows whose name starts with "Safari Tabs Backup") tell _doc set _url to contents of line 1 if _url is not "" then set _url to last text item of _url delete line 1 end if end tell end tell tell application "Safari" if _url is not "" then set URL of front document to _url end if end tell
------------------------------------------------------------------------------------------------
|