Last active
January 9, 2017 21:29
-
-
Save artifactsauce/05f3f84b47eff01a377707f0ef8aed8a to your computer and use it in GitHub Desktop.
JXAでChromeの新規Windowに複数のタブを開く ref: http://qiita.com/artifactsauce/items/02da9a29491519cb198b
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
set pages to {"http://www.yahoo.co.jp/", "https://google.co.jp/"} | |
tell application "Google Chrome" | |
repeat with page in pages | |
open location page | |
delay 0.1 | |
end repeat | |
activate | |
end tell |
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
# このように書くことはできない | |
set pages to { | |
"https://www.yahoo.co.jp/", | |
"http://www.google.co.jp/" | |
} |
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
Application('Google Chrome').Window().make(); |
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
Application('Google Chrome').Window().make(); |
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
var tab = Application('Google Chrome').Tab({url:page}); | |
Application('Google Chrome').windows()[0].tabs.push(tab); |
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
var win = Application('Google Chrome').Window(); | |
Application('Google Chrome').windows.push(win); |
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
//usr/bin/osascript -l JavaScript $0 $@; exit |
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
//usr/bin/osascript -l JavaScript $0 $@; exit | |
var pages = [ | |
"http://www.yahoo.co.jp/", | |
"http://www.google.co.jp/" | |
]; | |
var app = Application('Google Chrome'); // アプリケーションを取得する | |
var win = app.Window().make(); // 新規ウィンドウを開く | |
pages.forEach(function(page, i) { | |
if (i === 0) { | |
// 新規ウィンドウには空のタブがあるという前提 | |
win.tabs()[0].url = page; // 指定したURLを開く | |
} | |
else { | |
var tab = app.Tab({url:page}); // Tabオブジェクトを作成する | |
win.tabs.push(tab); // ウィンドウに配置する | |
} | |
if (i !== pages.length - 1) { | |
delay(0.1); // ちょっと待つ | |
} | |
}); | |
app.activate(); // ウィンドウを最前面に移動する |
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
$ osacompile -l JavaScript -x -o ~/Desktop/open-pages.app ./open-pages.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment