Skip to content

Instantly share code, notes, and snippets.

@oal
Created December 25, 2014 13:21
Show Gist options
  • Save oal/e965bc6fd031f27f9f86 to your computer and use it in GitHub Desktop.
Save oal/e965bc6fd031f27f9f86 to your computer and use it in GitHub Desktop.
Restart Safari and reopen all windows and tabs from previous session.
function run() {
// Quit
var safari = Application('Safari');
safari.activate();
safari.quit()
// Reopen safari
safari.activate();
// Get menu
var se = Application('System Events');
var proc = se.processes.byName('Safari');
var logMenu = proc.menuBars[0].menuBarItems[5];
// Reopen from last session
// Replace string with whatever "Open all windows from previous session" is in your language
logMenu.menus[0].menuItems.byName('Åpne alle vinduer fra forrige økt på nytt').click();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment