Safari 扩展注入的内容应该如何工作?
这是一个令人困惑的基本问题,谷歌无法提供帮助。我有一个 Safari 扩展,它似乎可以在很多方面工作:我有一个证书,我有一个可以检查的全局页面,我添加了一个上下文菜单项,我有一个 javascript 文件,从全局页面,接收选择上下文菜单项时触发的事件。
但是,如果我添加结束脚本或样式表,即使我已将扩展网站访问级别设置为全部,也不会发生任何情况。即使我卸载并重新安装扩展,和/或重新加载活动网站,也没有任何结果。注入的 javascript 中对 window.console.log() 的调用不会运行,脚本和 css 文件都不会出现在 Web 检查器的资源列表中,无论是“资源”还是“脚本”选项卡,都没有。
关于我可以做什么来进一步调试这个问题有什么想法吗?
This is a bafflingly basic question that Google is unable to help. I have a Safari extension that appears to work in many ways: I've got a certificate, I've got a global page which I can inspect, I've added a contextual menu item and I have a javascript file, loaded from the global page, which receives the events fired when the contextual menu item is chosen.
But if I add an end script or a style sheet, nothing happens, even though I've set Extension Website Access Level to All. Even if I uninstall and reinstall the extension, and/or reload the active website, nothing. Calls to window.console.log() in injected javascript don't get run, neither scripts nor css files appear in the list of resources in the web inspector, either the Resources or Scripts tabs, nothing.
Any ideas as to what I could do to debug this problem further?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您可能没有在扩展生成器的注入的扩展内容标题下选择注入的脚本。如果这样做,请尝试重新启动 Safari 并重新加载扩展。
Sounds like maybe you didn't select your injected script under the Injected Extension Content heading of the Extension Builder. If you did, then try restarting Safari and reloading the extension.