AppleScript 可以访问浏览器选项卡并在其中执行 javascript 吗? [英] Can AppleScript access browser tabs and execute javascript in them?

查看:36
本文介绍了AppleScript 可以访问浏览器选项卡并在其中执行 javascript 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇 AppleScript 是否可以访问浏览器中的每个特定选项卡并在其中执行一些 javascript.

I'm curious if AppleScript can access each specific tab in a browser and execute some javascript in them.

有人有想法吗?

推荐答案

对于 Google Chrome,使用 AppleScript Chromium Suite 中的 execute:

For Google Chrome, use execute from AppleScript Chromium Suite:

execute v : 执行一段javascript.

execute v : Execute a piece of javascript.

execute specifier :在其中执行命令的选项卡.

execute specifier : The tab to execute the command in.

javascript text :要执行的 javascript 代码.

javascript text : The javascript code to execute.

示例:

tell application "Google Chrome"
    execute front window's active tab javascript "alert('example');"
end tell

可以在 Safari 中完成:

tell application "Safari" to do JavaScript "alert('example')" in document 1

对于其他浏览器,检查File -> 中的功能;在 AppleScript 编辑器上打开字典.

For other browsers, check the functions at File -> Open Dictionary on AppleScript editor.

这篇关于AppleScript 可以访问浏览器选项卡并在其中执行 javascript 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆