Last active
May 6, 2019 05:56
-
-
Save yume-yu/a262c54de1988fcc6c26e4eca29fa12c to your computer and use it in GitHub Desktop.
safari/Chromeでwebページをアプリケーションっぽく立ち上げるJavascript(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
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){ | |
} |
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
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(); | |
} |
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
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