Last active
August 29, 2015 14:18
-
-
Save irskep/372ec06c16df621828ca to your computer and use it in GitHub Desktop.
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
| var Safari = Application('Safari'); | |
| var SystemEvents = Application('System Events'); | |
| var SafariEvents = SystemEvents.processes['Safari']; | |
| var openDevTools = function(deviceName, appName) { | |
| var getDevSubMenuItem = function(i) { | |
| return SafariEvents.menuBars[0] | |
| .menuBarItems['Develop'].menus['Develop'] | |
| .menuItems[deviceName].menus[deviceName] | |
| .menuItems[i]; | |
| } | |
| try { | |
| console.log("Finding correct menu..."); | |
| var labelIndex = 0; | |
| while (getDevSubMenuItem(labelIndex).name() != appName) { | |
| console.log("Skipping " + getDevSubMenuItem(labelIndex).name()); | |
| labelIndex += 1; | |
| } | |
| getDevSubMenuItem(labelIndex + 1).click(); | |
| Safari.activate(); | |
| return true; | |
| } catch (e) { | |
| return false; | |
| } | |
| } | |
| var didSucceed = false; | |
| while (!didSucceed) { | |
| console.log("Attempting to open dev tools"); | |
| delay(1); | |
| didSucceed = openDevTools("Slam Jamsen's iPhone", "HTML5 Fart App 2.0"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment