How to get last active tab in Safari using AppleScript

applescriptautomatorsafari

I'm pretty new to AppleScript and wanted to make a simple script for Safari.
In fact, I want to activate the last active tab after closing the current tab.
This is where I'm stuck

tell application "Safari"
    close current tab of front window
    set current tab #(some code to get last active tab) 
end tell

Best Answer

Answer: this is not possible since the list of active previous tabs isn’t stored in a way AppleScript can know how to go back and undo a window close operation.