Whole content of the Activity window (Window: Activity, or Command-Option-A) in Safari can be copied to clipboard with regular "select - copy-to-clipboard" sequence. This means you may copy multiple URLs from some or all Safari tabs at once, and paste them to bookmarks, preserving state of the tabs without any scripts.
If all tabs representations in the Activity window are collapsed, you may just select all (Command-A), copy (Command-c), create a new bookmark folder (Command-Shift-N) and paste (Command-V) the copied URLs to the new folder. This way you may always restore the state of your browser without any additional scripts! You may even select just some of opened tabs with regular Command-clicks, and copy only the selected items. Of course, you may paste all those URLs to any text document instead of bookmarks. Flexibility is unlimited!
Mac OS X Hints
http://hints.macworld.com/article.php?story=20060822221657667