简体   繁体   English

Safari扩展可以对创建新选项卡做出反应吗?

[英]Can a Safari Extension react on the creation of a new tab?

I am currently writing my first extension for Safari 5. I can't find a reference on what events an extension can react. 我目前正在为Safari 5编写第一个扩展程序。我无法找到扩展可以响应的事件的参考。

I want my extension to react on these events: 我希望我的扩展程序对这些事件作出反应:

  • when a new tab is created. 何时创建新选项卡。
  • when a new browser window is created. 何时创建新的浏览器窗口。
  • when the URL inside a tab changes. 当标签内的URL发生变化时。

Is this possible? 这可能吗?

Yes. 是。 Create an Injected Script and add it as an End Script. 创建注入脚本并将其添加为结束脚本。 Set the Access Level of Extension Website Access in the builder to All. 将构建器中的扩展站点访问的访问级别设置为全部。 Your Injected End Script will be called for every page that loads in Safari, which covers all of the cases you mentioned. 您将在Safari中加载的每个页面调用您的注入结束脚本,其中包含您提到的所有案例。

Yes, as of version 5.1 是的,从5.1版开始

From the Safari documentation : Safari文档

In Safari 5.1 and later, you can listen for and respond to the following window and tab events: 在Safari 5.1及更高版本中,您可以侦听并响应以下窗口和选项卡事件:

Open—Safari sends an "open" event to a window or tab when it is first opened. Open-Safari在首次打开时向窗口或选项卡发送“打开”事件。

... ...

Navigate—Safari sends a "navigate" event to a tab when the main frame of the new URL has loaded. 当加载新URL的主框架时,Navigate-Safari会向选项卡发送“导航”事件。

Here is the reference: The Windows and Tabs API 以下是参考: Windows和Tabs API

Edit: Hmm... it seems it only documents how to do some actions, not how to listen to events :-/ 编辑:嗯......似乎它只记录如何做一些动作,而不是如何听事件: - /

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM