var TBWW = {
_observingOn: null,
startHTTPObserver: function() {
if (!this._observingOn) {
var s = Cc['@mozilla.org/observer-service;1'].getService(Ci.nsIObserverService);
s.addObserver(this.observer, 'http-on-modify-request', false);
this._observingOn = true;
}
},
stopHTTPObserver: function() {
if (this._observingOn) {
var s = Cc['@mozilla.org/observer-service;1'].getService(Ci.nsIObserverService);
s.removeObserver(TBWW.observer, 'http-on-modify-request', false);
TBWW._observingOn = false;
}
},
observer: {
observe: function(aSubject, aTopic, aData) {
aSubject.QueryInterface(Ci.nsIHttpChannel);
var url = aSubject.URI.spec;
////////////////////////////////
var aFile = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile);
aFile.initWithPath('C://temp//temp.txt');
var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"].
createInstance(Components.interfaces.nsIFileOutputStream);
foStream.init(aFile, 0x02 | 0x10, 0666, 0);
var converter = Components.classes["@mozilla.org/intl/converter-output-stream;1"].
createInstance(Components.interfaces.nsIConverterOutputStream);
converter.init(foStream, "UTF-8", 0, 0);
converter.writeString(url + "/n");
converter.close(); // this closes foStream
foStream.close();
////////////////////////////////
},
},
}
window.addEventListener("dblclick", function(e) { doTest(); }, false);
function doTest() {
if (TBWW._observingOn) {
TBWW.stopHTTPObserver();
alert("stopped HTTP Observer");
} else {
TBWW.startHTTPObserver();
alert("startted HTTP Observer");
}
}