่ชญ่€…ใงใ™ ่ชญ่€…ใ‚’ใ‚„ใ‚ใ‚‹ ่ชญ่€…ใซใชใ‚‹ ่ชญ่€…ใซใชใ‚‹

๐ŸŽ Google Chrome ใง้–‹ใ„ใฆใ„ใ‚‹ใ‚ฟใƒ–ใฎ URL ใจใ‚ฟใ‚คใƒˆใƒซใ‹ใ‚‰ใ‚ขใƒณใ‚ซใƒผใƒ†ใ‚ญใ‚นใƒˆใ‚’ไฝœๆˆใ™ใ‚‹

Google Chrome

Google Chrome ใ‹ใ‚‰้–‹ใ„ใฆใ„ใ‚‹๏ผˆใ‚ขใ‚ฏใƒ†ใ‚ฃใƒ–ใช๏ผ‰ใ‚ฟใƒ–ใ‹ใ‚‰ URL ใจใ‚ฟใ‚คใƒˆใƒซใ‚’ๅ–ๅพ—ใ—ใ€<a rel="external" href="URL">TITLE</a> ใช HTML ใ‚’็”Ÿๆˆใ—ใฆใ‚ฏใƒชใƒƒใƒ—ใƒœใƒผใƒ‰ใธใ‚ณใƒ”ใƒผใ—ใพใ™ใ€‚


ใ‚นใ‚ฏใƒชใƒ—ใƒˆๅ…จไฝ“

tell application "Google Chrome" to set L to {URL of active tab of window 1, title of active tab of window 1}
set item 2 of L to do shell script "LANG=ja_JP.UTF-8 /usr/bin/ruby -ne 'require \"cgi\"; puts CGI.escapeHTML($_)' <<<" & quoted form of item 2 of L
set the clipboard to "<a rel=\"external\" href=\"" & item 1 of L & "\" title=\"" & item 2 of L & "\">" & item 2 of L & "</a>"

1่กŒ็›ฎ

ๆ™ฎ้€šใซๆ›ธใใจไธ‹่จ˜ใฎใ‚ˆใ†ใชใ‚ณใƒผใƒ‰ใซใชใ‚‹ใ‹ใจๆ€ใ„ใพใ™ใŒ Google Chrome ใฏ1ๅบฆใ—ใ‹ๅ‘ผใฐใชใ„ใฎใงใƒชใ‚นใƒˆใ‚’ไฝฟใฃใฆ1่กŒใงๆธˆใพใ›ใฆใ„ใพใ™ใ€‚Google Chrome.sdef ใ‚’่ชญใ‚€ใจใ‚ฟใƒ–ใฎๆƒ…ๅ ฑใฏ tab {n} ใงๆ‹พใˆใ‚‹ใ‚ˆใ†ใชๆฐ—ใŒใ™ใ‚‹ใ‚“ใงใ™ใŒ active tab ใ˜ใ‚ƒใชใ„ใจๅ–ๅพ—ใงใใชใ„ใ‚ˆใ†ใงโ€ฆใ€‚

tell application "Google Chrome"
    set theURL to URL of active tab of window 1
    set theTITLE to title of active tab of window 1
end tell

2่กŒ็›ฎ

ๅ–ๅพ—ใ—ใŸใ‚ฟใ‚คใƒˆใƒซใ‹ใ‚‰ใ‚จใ‚นใ‚ฑใƒผใƒ—ใŒๅฟ…่ฆใซใชใ‚‹ๆ–‡ๅญ—ใ‚’ Ruby ใ‚’ไฝฟใฃใฆๅค‰ๆ›ใ—ใฆใ„ใพใ™ใ€‚Ruby ใ‚นใ‚ฏใƒชใƒ—ใƒˆ้ƒจๅˆ†ใซ็›ดๆŽฅๆ–‡ๅญ—ๅˆ—ใ‚’ๅŸ‹ใ‚่พผใ‚“ใงใ—ใพใ†ใจ่ชคไฝœๅ‹•ใ‚’่ตทใ“ใ™ๅฏ่ƒฝๆ€งใŒใ‚ใ‚‹ใŸใ‚ quoted form of ๅŒ–ใ—ใŸใ‚‚ใฎใ‚’ใƒ’ใ‚ขใ‚นใƒˆใƒชใƒณใ‚ฐใ‚’ไฝฟใฃใฆๆจ™ๆบ–ๅ…ฅๅŠ›ใ‹ใ‚‰่ชญใฟ่พผใพใ›ใพใ™ใ€‚AppleScript ใฎ do shell script ็’ฐๅขƒใงใฏใ‚ทใ‚งใƒซใฎๅˆๆœŸ็’ฐๅขƒๅค‰ๆ•ฐใŒใ‚ฟใƒผใƒŸใƒŠใƒซ็ญ‰ใจใฏ็•ฐใชใ‚‹ใŸใ‚ LANG=ja_JP.UTF-8 ใ‚„ Ruby ใฎ -Ku ใ‚ชใƒ—ใ‚ทใƒงใƒณใ‚’ๆŒ‡ๅฎšใ—ใชใ„ใจใ‚จใƒฉใƒผใซใชใ‚‹ใ“ใจใŒใ‚ใ‚Šใพใ™ใ€‚ใ‚ฟใ‚คใƒˆใƒซใซๆ”น่กŒใ‚ณใƒผใƒ‰ใŒๅ…ฅใฃใฆใ„ใ‚‹ใ“ใจใฏใพใš็„กใ„ใจๆ€ใ†ใฎใง -n ใ‚ชใƒ—ใ‚ทใƒงใƒณใฏ่ฆใ‚‰ใชใ„ใ‹ใ‚‚ใ—ใ‚Œใพใ›ใ‚“ใ€‚

LANG=ja_JP.UTF-8 /usr/bin/ruby -ne 'require "cgi"; puts CGI.escapeHTML($_)' <<<'TITLE OF ACTIVE TAB'

3่กŒ็›ฎ

URL ใจใ‚ฟใ‚คใƒˆใƒซใ‹ใ‚‰ HTML ใ‚’็”Ÿๆˆใ—ใ€ใ‚ฏใƒชใƒƒใƒ—ใƒœใƒผใƒ‰ใธใ‚ณใƒ”ใƒผใ—ใฆใ„ใพใ™ใ€‚

็”Ÿๆˆไพ‹

Yahoo! JAPAN ใฎใƒšใƒผใ‚ธใ‹ใ‚‰ไปฅไธ‹ใฎใ‚ณใƒผใƒ‰ใŒ็”Ÿๆˆใ•ใ‚Œใพใ™ใ€‚

<a rel="external" href="http://www.yahoo.co.jp/" title="Yahoo! JAPAN">Yahoo! JAPAN</a>

AppleScript: The Definitive Guide: Scripting and Automating Your Mac (Definitive Guides)

AppleScript: The Definitive Guide: Scripting and Automating Your Mac (Definitive Guides)

Learn AppleScript: The Comprehensive Guide to Scripting and Automation on Mac OS X (Learn Series)

Learn AppleScript: The Comprehensive Guide to Scripting and Automation on Mac OS X (Learn Series)