I'm trying to port my Google Chrome extension to Firefox Add-On SDK and I need the extension to filter pages from my website and make redirects. For example, if the user opens "http://example.com/special" I need to send him to "http://example.com/redirect" in the same browser tab.
This is how I tried to do this:
var pageMod = require("page-mod").PageMod({
include: "*",
contentScriptWhen: "start",
contentScript: "",
onAttach: function(worker) {
if (worker.tab.url == worker.url &&
worker.url.indexOf("example.com/special") > -1) {
worker.tab.url = "http://example.com/redirect";
}
}
});
Problem is: my browser hangs sometimes after the redirect (immediately after the new page has been displayed in a tab). What am I doing wrong?
Using Firefox 16.0.2, Add-On SDK 1.11