Skip to content

Instantly share code, notes, and snippets.

@yume-yu
Last active May 6, 2019 05:56
Show Gist options
  • Save yume-yu/a262c54de1988fcc6c26e4eca29fa12c to your computer and use it in GitHub Desktop.
Save yume-yu/a262c54de1988fcc6c26e4eca29fa12c to your computer and use it in GitHub Desktop.
safari/Chromeでwebページをアプリケーションっぽく立ち上げるJavascript(JXA)
function openApp(tab,width,height){
delay(1);
var scr = "window.open('https://anime.dmkt-sp.jp/animestore/tp_pc', 'DanimeStore', 'top= 0, left="+(height-820)+", width=820, height=484, toolbar=yes')";
tab.execute({javascript: scr});
}
var app = Application("System Events");
var displayWidth = 1050;
var displayHeight = 1680;
app.activate();
app.includeStandardAdditions = true;
var safari = Application("Google\ Chrome.app");
safari.includeStandardAdditions = true;
safari.activate();
var window = safari.Window().make();
var tab = window.activeTab();
var old;
openApp(tab,displayWidth,displayHeight);
old = safari.windows[1];
try{
old.close();
}catch(e){
}
function openGbf(safari,i){
var scr = "window.open('http://game.granbluefantasy.jp/#mypage', 'mywindow1', 'top=0, left=0"+i*385+", width=385, height=1000, menubar=no, toolbar=no, scrollbars=yes')"
safari.doJavaScript(scr, {in:safari.windows[0].currentTab()});
}
var app = Application("System Events");
app.activate();
app.includeStandardAdditions = true;
var num = app.displayDialog('How many open windows ?', { defaultAnswer: "1" }).textReturned;
var safari = Application("Safari.app");
safari.includeStandardAdditions = true;
safari.activate();
var window = safari.Document().make();
var tab = [window.tabs[0],window.tabs[1]];
var old;
var tmp;
openGbf(safari,0);1
if(num == 1){
old = safari.windows[1];
old.close();
}else{
old = safari.windows[2];
window = safari.Document().make();
old.close();
tmp=1;
for(var i = 0;i < num - 2; i++){
openGbf(safari,i+1);
old = safari.windows[2];
window = safari.Document().make();
old.close();
tmp = i+2;
}
openGbf(safari,tmp);
old = safari.windows[1];
old.close();
}
function openShiny(safari,width,height){
var scr = "window.open('https://shinycolors.enza.fun/home', 'shinycolors', 'top= "+(width-484)+", left="+(height-820)+", width=820, height=484, menubar=no, toolbar=no, scrollbars=yes')";
safari.doJavaScript(scr, {in:safari.windows[0].currentTab()});
}
var app = Application("System Events");
var displayWidth = 1050;
var displayHeight = 1680;
app.activate();
app.includeStandardAdditions = true;
var safari = Application("Safari.app");
safari.includeStandardAdditions = true;
safari.activate();
var window = safari.Document().make();
var tab = [window.tabs[0],window.tabs[1]];
var old;
var tmp;
openShiny(safari,displayWidth,displayHeight);1
old = safari.windows[1];
old.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment