如何向 safari 扩展添加 JavaScript 代码?
我创建了一个 safari 扩展程序,但我不知道如何将 javascript 代码添加到 safari 扩展程序?
I create a safari extension , but I don't kown how to add javascript code to safari extension?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Safari 扩展几乎完全是Javascript。这有点过于简单化了,但是如果没有 Javascript,你会创建什么样的扩展呢?您可以在任何 注入脚本 或在 全局 HTML 文件。有关在何处/何时/如何使用其中每一个的详细信息,请参见 有很好的记录。
除了您可以访问以 Safari 为中心的 API 之外,您可以放置在任何这些文件中的 Javascript 的性质没有什么特别之处。否则,它只是你为 Web 编写的旧 Javascript,只是框架本身有一些怪癖。许多人甚至使用 jQuery 或其他 JS 库来提供帮助,尽管它们增加的开销比我在大多数情况下建议的要多。
A Safari extension is almost entirely Javascript. That's a bit of an oversimplification, but what kind of extension have you created if there's no Javascript? You can write as much or as little JS as you like in any injected script or in a global HTML file. The details of where/when/how to use each of these is pretty well documented.
There's nothing particularly special about the nature of the Javascript that you can place in any of these files except that you do have access to a Safari-centric API. Otherwise, it's just the same old Javascript you'd write for the web with a few quirks of the framework itself. A lot of folks even include jQuery or other JS libraries to help, though they add more overhead than I'd recommend in most cases.
我认为你应该先读一下这篇文章。
Safari 扩展开发指南
I think you should read this first.
Safari Extension Development Guide