I’m developing a Firefox extension. A HTML page makes a XMLHttpRequest ,parses the response and display it on the page. I want to block this XML response and edit its content in order to affect the display.
According to Firefox Add-on SDK document, the page-mod module enables add-on developers to execute scripts in the context of specific web pages. Most obviously you could use page-mod to dynamically modify the content of certain pages. Like this:
var pageMod = require("page-mod");
pageMod.PageMod({
include: "*.org",
contentScriptWhen: 'end',
contentScript: 'document.body.innerHTML = ' +
' "<h1>Page matches ruleset</h1>";'
});
However, it seems don’t work with XML page and any other non-HTML content(say .jpg). Is there a solution? Any help will be appreciated.
P.S. The HTML page is flash-based therefore I can’t simply modify it with “page-mod”.
No, not with the Add-on SDK. In a regular extension you can use
nsITraceableChannelAPI for that: http://www.softwareishard.com/blog/firebug/nsitraceablechannel-intercept-http-traffic/