Last active
December 11, 2015 05:59
-
-
Save mbierman/4556236 to your computer and use it in GitHub Desktop.
Open Mobile Safari to a particular URL, set the user agent to iPhone, and center on screen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Sets Safari to iPhone user agent and loads mobile.walmart.comf | |
set theURL to "http://mobile.walmart.com" | |
tell application "Safari" to activate | |
tell application "Safari" | |
activate | |
try | |
tell window 1 to set current tab to make new tab with properties {URL:theURL} | |
on error | |
open location theURL | |
end try | |
tell application "System Events" | |
tell process "Safari" | |
click menu item "Safari iOS 5.1 — iPhone" of menu "User Agent" of menu item "User Agent" of menu "Develop" of menu bar item "Develop" of menu bar 1 | |
keystroke "r" using {command down} | |
end tell | |
end tell | |
end tell | |
-- Roughly an iPhone 5 dimension | |
tell application "Finder" | |
set screenSize to bounds of window of desktop | |
set screenWidth to item 3 of screenSize | |
end tell | |
tell application "System Events" | |
set myFrontMost to name of first item of ¬ | |
(processes whose frontmost is true) | |
end tell | |
set front_app to (path to frontmost application as Unicode text) | |
tell application front_app | |
activate | |
set bounds of window 1 to {0, 100, 350, 795} | |
end tell | |
-- Center the window | |
try | |
tell application myFrontMost | |
set windowSize to bounds of window 1 | |
set windowXl to item 1 of windowSize | |
set windowYt to item 2 of windowSize | |
set windowXr to item 3 of windowSize | |
set windowYb to item 4 of windowSize | |
set windowWidth to windowXr - windowXl | |
set bounds of window 1 to {¬ | |
(screenWidth - windowWidth) / 2.0, ¬ | |
windowYt, ¬ | |
(screenWidth + windowWidth) / 2.0, ¬ | |
windowYb} | |
end tell | |
end try |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment