是否可以在firefox插件的全局级别覆盖此功能?
const windowMediator = CC["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
windowMediator.getMostRecentWindow("navigator:browser");
答案 0 :(得分:0)
您可以使用https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/page-mod
pageMod.PageMod({
include: "*",
contentScriptWhen: 'start',
contentScript: 'unsafeWindow.function=yourFunction;'
});
PageMod在页面开始运行(contentScriptWhen: 'start'
)上的js之前在每个页面上注入js。而且我们通过XRayWrapper https://developer.mozilla.org/en-US/Add-ons/SDK/Guides/Content_Scripts/Accessing_the_DOM覆盖窗口函数。