Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Restore Tabs' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Restore Tabs
Authored by: CaptDeuce on May 18, '05 11:23:26AM

Instead of putting up an annoying "are you sure?" dialog, I'd rather have a gadget that simply remembers the tabs you did have in the last window (or three) when you closed it.

---
--
"Where's my other sock?" - A. Einstein



[ Reply to This | # ]
Restore Tabs
Authored by: robg on May 18, '05 12:05:23PM

Saft will do this -- it's on the 2004 Pick of the Week table. It's got a ton of other cool features, but it's not free...

-rob.



[ Reply to This | # ]
Restore Tabs
Authored by: sjk on May 18, '05 02:53:38PM

Since you brought up this off-topic ...

One reason I originally bought Saft was for its ability to save/restore Safari tabs. However, over time I found that feature to be of limited value because of several interface limitations, such as:

• The inability to review saved "tab sessions" to see how many and which pages will reopen.
• And no way to rename or otherwise reorganize saved tabs.
• It's only possible to delete one or all saved tabs at a time, i.e. no multi-item selection.
• Saved tabs are embedded in Safari's preferences file, without any import/export capability(!) That was certainly the most frustrating limitation after saved tabs mysteriously disappeared a few times; restoring a Safari prefs backup is an unacceptable way to recover them.

It also hasn't helped that the developer remains unresponsive to specific suggestions for improvements of those and other issues. And a feature like printing header/footer info in Safari 2.0 is easier use via printer presets than bringing up Saft's preferences. For now I'll see how well I can survive on Tiger without the few Saft features I do like before deciding whether it's worth paying for the 8.x upgrade, while keeping an eye on SafariStand development.

Now, back to the primary topic ...

I tried Taboo with Safari 1.3 and quickly realized it wasn't helpful when using cmd-W to close tabs/windows; I rarely click to close them. Intercepting cmd-Q has value but not enough to justify a plugin rather than simply changing that shortcut. Soon after installing Taboo I had trouble with "phantom" windows that only showed up under the Window menu or minimized to the Dock, but weren't actually displayed (maybe some obscure conflict with CodeTek Virtual Desktop).



[ Reply to This | # ]
Restore Tabs
Authored by: luai on May 18, '05 11:03:51PM

There were two nice scripts called: (Saving Session & Restoring Session).
They work very well under panther bun not anymore with tiger.
I don't remember their origin, but they were really helpful. you can save ALL your windows and tabs for a later session-hence the name.
I am posting the text of these scripts, so as any Scrip guru can help modifying them to work in Tiger.
Saving session:

-- localizations
property windowMenu : "Window"
property nextTabMenuItem : "Select Next Tab"
-- end localizations

property url_list : {}
property docCount : 0


tell application "Safari"
activate
set docCount to count of documents
end tell

tell application "System Events"
tell process "Safari"

set menuItemCount to count of menu items of menu windowMenu of ¬
menu bar 1
set menuItemOffset to menuItemCount - docCount

set url_list to {}

-- count the windows
set winCount to count of windows

-- loop through the windows
repeat with k from 1 to winCount

set winNum to k

set winTitle to title of window winNum

-- a bit nasty, but the front window is always number 1
set winNum to 1

if (count of characters of winTitle) > 20 then
set winTitle to text 1 thru 20 of winTitle
end if

repeat with j from menuItemOffset + 1 to menuItemCount
if ((title of menu item j of menu windowMenu of menu bar 1) ¬
starts with winTitle) then
set itemNum to j
exit repeat
end if
end repeat

-- activate a window
click menu item itemNum of menu windowMenu of menu bar 1

set firstUrl to ""

-- check for browser window
if (count of radio buttons of window winNum) > 0 then

-- activate the first tab
click radio button 1 of window winNum

-- url of first tab
set firstUrl to value of text field 1 of group 1 ¬
of splitter group 1 of window winNum

-- save the url
set url_list to url_list & firstUrl

my nextTab()

-- url of the next tab
set nextUrl to value of text field 1 of group 1 ¬
of splitter group 1 of window winNum

repeat until firstUrl is equal to nextUrl

-- save the last url
set url_list to url_list & nextUrl

my nextTab()

-- url of next tab
set nextUrl to value of text field 1 of group 1 ¬
of splitter group 1 of window winNum

end repeat

-- empty line to seprate windows
set url_list to url_list & ""

end if

end repeat
end tell
end tell

-- convert url list to text
set old_delim to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set url_list_text to url_list as text
set AppleScript's text item delimiters to old_delim

-- get path to prefs file where URLs will be stored
set prefs_folder to path to preferences folder as string
set prefs_file to prefs_folder & "Safari Saved URLs"

try
set open_file to ¬
open for access file prefs_file with write permission
-- erase current contents of file:
set eof of open_file to 0
write url_list_text to open_file starting at eof
close access open_file
on error
try
close access file prefs_file
end try
end try

-- let the user know we are done.
tell application "Safari"
activate
display dialog "All Done" buttons {"OK"} default button 1
end tell


on nextTab()
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
click menu item nextTabMenuItem of ¬
menu windowMenu of menu bar 1
end tell
end tell
end nextTab

Restoring Session:

tell application "Safari" to activate

-- get path to prefs file where URLs are stored
set prefs_folder to path to preferences folder as string
set prefs_file to prefs_folder & "Safari Saved URLs"

try
-- read the saved urls
set open_file to ¬
open for access file prefs_file without write permission
set url_list to read open_file using delimiter return
close access open_file

set tmpList to {}
set newUrl_list to {}

-- make urls from file into a list of lists
-- each window is a seperate list in the big list
repeat with aURL in url_list
if aURL & "x" is "x" then
set newUrl_list to newUrl_list & {tmpList}
set tmpList to {}
else
set tmpList to tmpList & aURL
end if
end repeat

-- don't forget the last list, or maybe the only
set newUrl_list to newUrl_list & {tmpList}

tell application "Safari"

-- loop through the list of windows
repeat with urls in newUrl_list

my new_window()
set emptyWindow to true

-- loop through the list of tabs
repeat with aURL in urls
if emptyWindow then
set emptyWindow to false
else
my new_tab()
end if

-- open the url
set URL of document 1 to aURL

end repeat

end repeat
end tell
on error
try
close access file prefs_file
end try
end try

-- let the user know we are done.
tell application "Safari"
activate
display dialog "All Done" buttons {"OK"} default button 1
end tell

on new_tab()
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
click menu item "New Tab" of menu "File" of menu bar 1
end tell
end tell
end new_tab

on new_window()
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
click menu item "New Window" of menu "File" of menu bar 1
end tell
end tell
end new_window



[ Reply to This | # ]
Restore Tabs
Authored by: kadis on May 18, '05 11:24:09PM
I believe it may be from Daring Fireball: Save and Restore Safari URLs < http://daringfireball.net/2003/02/save_and_restore_safari_urls >

[ Reply to This | # ]
saving/restoring tabs
Authored by: sjk on May 19, '05 11:50:04PM

And there've been several variations of the script posted here on MacOSXHints. Shortcomings aside, Saft's method of saving/restoring tabs was the most reliable for me.



[ Reply to This | # ]
Restore Tabs
Authored by: osxpounder on May 18, '05 01:59:59PM

Opera has it -- or something close, if I understand you correctly. One of the many nice things about Opera that had me using it for years on Mac and PC was the feature that remembered what windows you had open last, and re-opened them, if you wished, next time you loaded Opera. It wasn't ideal -- you were asked, when starting Opera, if you wanted to re-open the windows you last used, but unless you remembered, you'd have no idea what they were, or how many. This means you could click "Yes" and wait, wait, wait for 5 or more windows to load their URLs. Or, you could find what some other person had last viewed in Opera on the same computer. What you couldn't do, AFAIK, was see a list of the URLs you had open at the time you last quit Opera.

It worked with windows or tabs, though.

---
--
osxpounder



[ Reply to This | # ]
Restore Tabs
Authored by: nicka on May 18, '05 06:00:21PM

Why doesn't any browser have an Undo button that restores the last tab or window you shut?

And is there a browser that can list your browsing history by last-closed instead of last-opened? That way if you closed a tab by mistake it would be at the top of the history list to be easily re-opened. A _really_ smart browser would keep the last few closed tabs cached so that they would re-open instantly.

Just dreaming, I suppose...



[ Reply to This | # ]
Restore Tabs
Authored by: jonte on May 19, '05 04:38:26AM

Opera does this.



[ Reply to This | # ]
Restore Tabs - UndoCloseTab
Authored by: knujon on May 19, '05 01:27:27PM

Firefox users can install an extension that does just that -- undo a closed tab. The extension is called 'undoclosetab,' by "Dorando." Note that as of today (May 19, 2005) the 'Install' link on the Firefox Extension page for this extension does not work; you need to get the file from the author at http://mozilla.dorando.at/undoclosetab.xpi, choose Open from within Firefox, select the .xpi file, and install it that way. It adds "Undo Close Tab" to the context menu when right-clicking any tab.



[ Reply to This | # ]