tell application "Google Chrome"
activate
tell window 1
tell active tab
set theURL to URL as text
end tell
end tell
end tell
tell application "Finder"
activate
set objAns to ¬
display alert ¬
"どちら用のQRコードを作成しますか?" message ¬
"iOS用AppleMapのQRコードを作成する OR 一般的なQRコードを作成する" default button 1 ¬
buttons {"AppleMap用", "GoogleMap用", "汎用"}
end tell
set AppleScript's text item delimiters to {"/"}
set listUrl to every text item of theURL as list
set numCntUrl to (count of listUrl) as number
set numSepUrl to 1 as number
set AppleScript's text item delimiters to {""}
log numCntUrl
repeat numCntUrl times
set theSepUrl to (item numSepUrl of listUrl) as text
try
set theUrlParts to (the character 1 of theSepUrl)
on error
set theUrlParts to " "
end try
if theUrlParts is "@" then
set theGooglemapParts to theSepUrl
set theSepUrl to doReplace(theSepUrl, "@", "")
set AppleScript's text item delimiters to {","}
set listSepUrl to every text item of theSepUrl as list
set theLatitude to (item 1 of listSepUrl) as text
set theLongitude to (item 2 of listSepUrl) as text
set AppleScript's text item delimiters to {""}
end if
set numSepUrl to numSepUrl + 1 as number
end repeat
if (button returned of objAns) is "AppleMap用" then
set theChl to ("GEO:" & theLatitude & "," & theLongitude & "") as text
log theChl
else if (button returned of objAns) is "GoogleMap用" then
set theChl to ("https://www.google.com/maps/" & theGooglemapParts & "") as text
else
set theChl to ("http://maps.apple.com/?q=" & theLatitude & "," & theLongitude & "") as text
end if
set theApiUrl to "https://chart.googleapis.com/chart?" as text
set theCht to "qr" as text
set theChs to "540x540" as text
set theChoe to "UTF-8" as text
set theChld to "Q" as text
set theOpenUrl to ("" & theApiUrl & "&cht=" & theCht & "&chs=" & theChs & "&choe=" & theChoe & "&chld=" & theChld & "&chl=" & theChl & "") as text
tell application "Google Chrome"
activate
tell window 1
set active tab index to 1
make new tab
tell active tab
set URL to theOpenUrl
end tell
end tell
end tell
to doReplace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end doReplace