Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moyashi/994136 to your computer and use it in GitHub Desktop.
Save moyashi/994136 to your computer and use it in GitHub Desktop.
Google Chromeで表示中のページタイトルとURLをカーソル位置にリンクで貼り付けるTypeIt4Me( http://bit.ly/iorZdU )用スクリプト
global format
--リンクの書式を変える場合はformatを変更
set format to "<a href=\"$url$\" target=\"_blank\">$title$</a>"
set isRunning to isRunning("Google Chrome") of me
if (isRunning) then
do() of me
end if
on do()
tell application "Google Chrome"
if ((count of window) is greater than 0) then
tell active tab of window 1
set u to URL
set t to title
set tmp to my replace(format, "$title$", t)
set tmp to my replace(tmp, "$url$", u)
return tmp
end tell
else
return ""
end if
end tell
end do
on replace(str, org, rep)
try
set oldDel to AppleScript's text item delimiters
set AppleScript's text item delimiters to org
set myList to text items of str
set AppleScript's text item delimiters to rep
set res to myList as string
set AppleScript's text item delimiters to oldDel
on error
set AppleScript's text item delimiters to oldDel
end try
return res
end replace
on isRunning(appname)
tell application "System Events"
return (count of (every process whose name contains appname)) is greater than 0
end tell
end isRunning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment