如何检测 Mozilla 附加组件后台加载的 URL?

How to detect URLs loading in the background in Mozilla Add-on?

我正在为 Mozilla Firefox 附加组件编写脚本以检测后台加载的某些 URL 并使用 pageMod.PageMod 修改内容。目前我正在使用以下脚本:

var pageMod = require("sdk/page-mod");
    pageMod.PageMod({
      include: ["*.maxcdn.com","*.googleapis.com","192.168.1.1"],
      contentScript: 'window.alert("This website is using CDN/localhost");'
    });

上述脚本的问题是它只检测父级(主要URL)而不是后台加载scripts/css。

WebRequest.jsm 可以检测所有请求。

还有构建 WebRequest 的低级原语 (http observers and content policies)。但它们更难实现。