监听 URL 位置 Firefox 扩展

发布于 2024-11-19 04:13:21 字数 698 浏览 4 评论 0原文

我需要检测用户何时更改为 PDF 页面,例如: w4 Form< /a>.我知道如何使用 document.location.hrefdocument.URL 获取当前页面的 URL。它们都工作正常,但是当加载 PDF 页面时,这些调用不起作用。

我正在通过 page-mod 插入内容脚本。代码如下:

var pageMod = require("page-mod");
pageMod.PageMod({
    include: "*",
    contentScriptWhen: 'start',
    contentScript: 'console.log(document.location.href);'
});

所以我猜测您无法将内容脚本插入 PDF 页面。当用户位于 PDF 页面内时,我必须采用哪些替代方法来检测?

在 Chrome 中,我可以通过分配背景页面来做到这一点。是否有类似的方法可以使用附加 SDK 来执行此操作?我查看了 page-worker 但我也找不到任何东西,因为它只是一个不可见的页面而不是背景页面。

I need to detect when the user changes to a PDF page, for example: w4 Form. I know how to get the URL of the current page by either using document.location.href or document.URL. They both work fine, however when a PDF page is loaded those calls do not work.

I am inserting a content script through page-mod. The code is the following:

var pageMod = require("page-mod");
pageMod.PageMod({
    include: "*",
    contentScriptWhen: 'start',
    contentScript: 'console.log(document.location.href);'
});

So I am guessing that you cannot insert a content script into a PDF page. What alternatives do I have to detect when a user is inside a PDF page?

In Chrome I am able to do this by assigning a background page. Is there a similar way to do this with the Add-on SDK? I looked at page-worker but I couldn't find anything there either since it is just an invisible page and not a background page.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文