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


Click here to return to the '10.3.2 Update' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.3.2 Update
Authored by: mazatty on Jan 17, '04 07:32:21PM
Here is the updated save script for 10.3.2 (Panther). enjoy.


-- 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



[ Reply to This | # ]
10.3.2 Update works perfectly
Authored by: Safar on Jan 21, '04 10:25:52AM

your update works fine. thank you.



[ Reply to This | # ]
10.3.2 Update Seing Double
Authored by: harywilke on Jan 28, '04 12:34:39PM

when i run the save script it cycles though my tabs twice.
not suprisingly when i run the restore it opens two windows full of restored tabs.

any idea? why i'd be getting doubles? and is GUI scripting now part of the default install for 10.3? i couldn'd find where to download it and the option to enable it under SystemPreferences>UniversalAccess was avalable so i just clikced that



[ Reply to This | # ]
Works nice but...
Authored by: kmue on Feb 02, '04 08:22:12AM
The Update works nice but unfortunatley the tabs of the last window are recorded twice. So if you have just one window with tabs they are all recorded twice.

[ Reply to This | # ]
Works nice but...
Authored by: penum6ra on Feb 23, '04 01:57:12AM

Any fix to this yet?
This is still happening for me too... but the feature is great despite!



[ Reply to This | # ]