firefox - 为什么脚本编辑器不喜欢这个编辑?
问题描述
我得到了他的剧本:
set vURL to URL of current tab of window 1
end tell
tell application "Google Chrome"
if windows ≠ {} then
make new tab at the end of window 1 with properties {URL:vURL}
else
make new window
set URL of (active tab of window 1) to vURL
end if
activate
end tell
我真的很希望能够在 Firefox 中快速打开我在 Safari 中使用的标签,因为...
有人告诉我必须在此处添加更多文本,因此请跳过本段。...我经常使用的网站在 Firefox 中有一些很棒的功能,但加载速度可能很慢,所以我喜欢在两者之间来回切换。
如果我将“Google Chrome”更改为“Firefox”,为什么它不起作用:
tell application "Safari"
set vURL to URL of current tab of window 1
end tell
tell application "Firefox"
if windows ≠ {} then
make new tab at the end of window 1 with properties {URL:vURL}
else
make new window
set URL of (active tab of window 1) to vURL
end if
activate
end tell
谢谢
解决方案
您不能混合和匹配脚本术语 - 给定应用程序的脚本术语(如果有)完全取决于开发人员,并且是该应用程序独有的。术语名称也没有标准或通用做法,因此不同应用程序的脚本术语之间的任何相似之处纯属巧合,不一定提供相同的功能。
查看Google Chrome vs Safari和Firefox的脚本字典:
- Firefox并没有真正的脚本字典,只有一个默认套件可用。具体来说,窗口没有
tab
、active tab
或URL
元素(URL
这里也假定来自StandardAdditions) - Safari窗口没有
active tab
属性。
您将需要tell
使用特定于该应用程序的术语,为其自己的声明定位每个应用程序。另请注意,尝试使用变量来保存应用程序名称是行不通的,因为在编译脚本时会查找每个应用程序的脚本术语。
(根据评论编辑)
要使用Firefox (Mojave 中的版本 69.0.1)打开当前Safari选项卡的 URL ,您可以执行以下操作:
tell application "Safari" to set theURL to (get URL of current tab of front window)
tell application "Firefox"
activate
open location theURL
end tell
推荐阅读
- swift - 由于“任务':core:linkReleaseFrameworkIos'的执行失败”,Xcode 在 Kotlin Multiplatform 上失败
- javascript - Jquery 只返回每个元素迭代的第一个计算
- regex - 从引号之间提取文本并添加第二个单词
- javascript - 数据表插件在我的项目中不起作用
- spring-boot - BootstrapMode 如何在 LAZY 和 DEFERRED 模式下对 @EnableJpaRepositories 起作用?
- c# - C#:DataGridView 数据源更新 - DataTable、List、BindingList 和 BindingSource?
- node.js - 如何在 package.json 中指定最小和最大依赖版本?
- azerothcore - 移动时施法
- mongodb - 在 MongoDB 中将 fullName 更改为 firstName、lastName
- java - 将 long 转换为 int 时出现奇怪的值