Created
October 19, 2018 15:18
-
-
Save whobutsb/0b1a887b96e092a8d4332a33dab2bc42 to your computer and use it in GitHub Desktop.
Opening Chrome Tabs in JXA
This file contains 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
// grab the chrome object | |
var chrome = Application('Google Chrome'); | |
// create a new chrome window | |
var window = chrome.Window().make(); | |
// set the links you want to open | |
var links = [ | |
"https://gmail.com", | |
"https://soundcloud.com", | |
"https://twitter.com", | |
"https://aws.amazon.com" | |
]; | |
// loop through the links | |
for(i=0; i < links.length; i++){ | |
// set the url for the tab | |
window.tabs[i].url = links[i]; | |
// check to see if we have a next tab | |
if(links[i + 1] !== undefined){ | |
// create a new tab and push it to the window | |
window.tabs.push(new chrome.Tab()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment