安装时自动重新加载
当脚本被注入到 safari 扩展中时,它会在页面加载时运行,这意味着当安装扩展时,注入的 javascript 将仅适用于新打开的页面或随后重新加载的页面。有谁知道如何确保 javascript 运行而无需重新加载?
或者,强迫用户加载...但这似乎有点危险。
When a script is injected in a safari extension it runs on page load, so that means when an extension is installed the injected javascript will only apply to newly-opened pages or pages which are reloaded afterwards. Does anyone know how to ensure the javascript is run without having to reload?
Alternatively, forcing users to load... this seems a bit dangerous though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我还尝试找到一种在安装时“执行”或“附加”脚本的方法。这在 Chrome 和 Firefox 中是可能的,无需重新加载页面。不幸的是,在 Safari 中,我还没有找到一种方法来做到这一点,而无需重新加载页面并让普通的 addContentScript 处理程序负责注入脚本。
要在安装扩展后直接重新加载所有 Safari 选项卡:
I've also tried to find a way to "execute" or "attach" a script on install. This is possible in Chrome and Firefox, without having to reload the page. Unfortunately in Safari I haven't found a way to do this without having to reload the page and let the normal addContentScript handlers take care of injecting the script.
To reload all Safari tabs directly after extension has been installed: