如何访问Add-on SDK中的窗口和文档

发布于 2024-12-21 22:33:50 字数 213 浏览 1 评论 0原文

我想在使用附加 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

可爱咩 2024-12-28 22:33:50

您可以通过内容脚本访问文档,从而访问 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文