Skip to content

Instantly share code, notes, and snippets.

@bacalj
Last active October 6, 2019 21:09
Show Gist options
  • Select an option

  • Save bacalj/c027e27eb2d86caf7a38f2753fc615df to your computer and use it in GitHub Desktop.

Select an option

Save bacalj/c027e27eb2d86caf7a38f2753fc615df to your computer and use it in GitHub Desktop.
open chrome tabs with JXA
/* create chrome instance */
chrome = Application("Google Chrome");
chrome.includeStandardAdditions = true;
/* make a new window and set its first tab */
win = chrome.Window().make();
win.tabs[0].url = "http://www.google.com";
/* make a new tab and push it into window we made */
tab = win.tabs.push(new chrome.Tab());
win.tabs[1].url = "http://www.apple.com";
/* destroy the extra window created originally on app opening */
chrome.windows.byId(1).close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment