A Side-by-Each AppleScript for Safari’s Tabs
The following AppleScript will take the current Safari tab and the tab to the immediate right and open them up ‘side by each’ for you to compare. I don’t use it all too often, but it seems a handy thing to have in my Scripts folder.
tell application "Finder" to set windSz to bounds of window of desktop
set w1 to item 1 of windSz
set w2 to item 3 of windSz
set h1 to item 2 of windSz
set h2 to item 4 of windSz
set pg1size to {(w2 - (w2 * 0.95)), (h1 + (h2 - (h2 * 0.9))), (w2 * 0.495), (h2 * 0.9)}
set pg2size to {(w2 * 0.505), (h1 + (h2 - (h2 * 0.9))), (w2 * 0.95), (h2 * 0.9)}
tell application "Safari"
activate
set tabNo to index of last tab of front window
set firstURL to URL of document 1
close current tab of first item of windows
set secondURL to URL of document 1
make new document
set URL of document 1 to firstURL
set bounds of window 1 to pg1size
set bounds of window 2 to pg2size
end tell
One obvious way to improve this script would be to take advantage of Safari’s “Move Tab to New Window” option in the Window menu of the application, since this command separates the the tabs but does not reload the page, making it super fast. As far as I can tell, however, this feature is not currently exposed to AppleScript, and so the script above will reload the page that is separated off from the main window. It works well otherwise.
(Dramatic element added by Blitzen Trapper.)
(By the way, to any French Canadian readers, please don’t take offense to the title of this post. Vive le Québec libre!)