监听 URL 位置 Firefox 扩展
我需要检测用户何时更改为 PDF 页面,例如: w4 Form< /a>.我知道如何使用 document.location.href
或 document.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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论