Skip to content

Instantly share code, notes, and snippets.

@whobutsb
Created October 19, 2018 15:18
Show Gist options
  • Save whobutsb/0b1a887b96e092a8d4332a33dab2bc42 to your computer and use it in GitHub Desktop.
Save whobutsb/0b1a887b96e092a8d4332a33dab2bc42 to your computer and use it in GitHub Desktop.
Opening Chrome Tabs in JXA
// 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