如何访问Add-on SDK中的窗口和文档
我想在使用附加 SDK 构建的扩展中获取活动窗口的 cookie 信息。我该怎么做?我在文档中找不到任何可以访问窗口或文档的方法。同样在一些论坛中,人们谈论没有访问它们的方式。难道真的还是不行吗?
I want to get active window's cookie information in an extension built with the Add-on SDK. How can I do this? I couldn't find any method in documentation that has access to window or document. Also in some forums, folks talk about there is no way to access to them. Is it really not possible still?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过内容脚本访问文档,从而访问 document.cookie;有关使用内容脚本的更多信息,请参阅文档:
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/modifying-web-pages-url.html
编辑:这里是一个简单的示例,允许您将当前选项卡的 cookie 数据提取到插件的主代码中:
https://github.com/canuckistani/jp-page-mod-cookie
You can access document and therefore document.cookie via a content script; for more on working with content scripts, see the documentation:
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/modifying-web-pages-url.html
Edit: here's a simple example that allows you to fetch cookie data for the current tab into the addon's main code:
https://github.com/canuckistani/jp-page-mod-cookie