使用AppleScript抓住从Web浏览器最前面的窗口的网址:该最终列表 [英] Using AppleScript to grab the URL from the frontmost window in web browsers: The definitive list
问题描述
我建了一个 [插件] [1] ,抓住在Safari最前面的窗口的URL,然后让你缩短使用tr.im API。工作甜。
I built a [widget][1] that grabs the URL from the frontmost window in Safari, then allows you to shorten it using the tr.im API. Works sweet as.
我想使这更灵活,所以我研究如何抓住从其他浏览器的URL。下面是在Safari中的工作AppleScript的:
I want to make this more flexible, so am investigating how to grab an URL from other browsers. Here's the AppleScript that works in Safari:
tell application "Safari"
return URL of front document as string
end tell
在<一个href=\"https://web.archive.org/web/20141112082406/http://hintsforums.macworld.com/showthread.php?t=32237\"相对=nofollow>一些挖,我决定下的可能的Firefox的工作(尽管一个人告诉我它不会为他工作,可能是一些扩展冲突):
After some digging, I determined that the following might work for Firefox (though one person has told me it doesn't work for him, possibly a conflict with some extension?):
tell application "Firefox"
set myFirefox to properties of front window as list
return item 3 of myFirefox
end tell
的注:以上是低于最佳实践的一个例子,依靠列表项的位置。请参阅以下为Firefox更好的解决方案的
我想要做的是在这里明确的当量建立一个列表,在Mac平台上所有现代浏览器:歌剧,卡米诺,羊群等
What I'd like to do is build a list here of the definitive equivalents for every modern browser on the Mac: Opera, Camino, Flock, etc.
更新:在我关于这个问题的研究,我碰到一个有用的线程上的 MacOSXHints.com 。最下边我的答案是基于讨论。
Update: In my research on the subject, I came across a helpful thread on MacOSXHints.com. Most of my answers below are based on that discussion.
更新2:我已经注册成立的AppleScript此页面上进入[构件] [1]。这似乎是工作膨胀。
Update 2: I've incorporated the AppleScript on this page into the [widget][1]. It seems to be working swell.
推荐答案
谷歌Chrome Mac版增加了用于获取URL的AppleScripting方法。
Google Chrome for Mac has added the AppleScripting method for getting the URL.
的https://sites.google.com/a/chromium.org/dev/developers/design-documents/applescript
tell application "Google Chrome"
get URL of active tab of window 1
end tell
这里更多的例子:
http://laclefyoshi.blogspot.com/2010/10/谷歌 - 铬 - ver.html
这篇关于使用AppleScript抓住从Web浏览器最前面的窗口的网址:该最终列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!