Firefox removed the pref that allowed easy overriding of the new tab page.
I thought I could use http-on-modify-request to listen for about:newtab but apparently going to about:newtab loads https://tiles.services.mozilla.com/v3/links/view so i tried to listen for that and do redirectTo but its not working its so weird. Anyone know why? Here’s my code:
var { interfaces: Ci, utils: Cu, classes: Cc, results: Cr } = Components;
Cu.import('resource://gre/modules/Services.jsm');
Cu.import('resource://gre/modules/devtools/Console.jsm');
var observers = {
'http-on-modify-request': {
observe: function (aSubject, aTopic, aData) {
console.info('http-on-modify-request: aSubject = ' + aSubject + ' | aTopic = ' + aTopic + ' | aData = ' + aData);
var httpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel);
var requestUrl = httpChannel.URI.spec
console.error('requestUrl:', requestUrl);
if (requestUrl == 'https://tiles.services.mozilla.com/v3/links/view') {
console.error('yes redir now!!');
// httpChannel.cancel(Cr.NS_BINDING_ABORTED);
httpChannel.redirectTo(Services.io.newURI('data:text/html,you went to about:newtab page and i replaced it with this', null, null));
}
},
reg: function () {
Services.obs.addObserver(observers['http-on-modify-request'], 'http-on-modify-request', false);
},
unreg: function () {
Services.obs.removeObserver(observers['http-on-modify-request'], 'http-on-modify-request');
}
}
};
//register all observers
for (var o in observers) {
observers[o].reg();
}