Skip to content

Instantly share code, notes, and snippets.

@claudiodangelis
Created November 20, 2014 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claudiodangelis/078951f9e684a4ef7a52 to your computer and use it in GitHub Desktop.
Save claudiodangelis/078951f9e684a4ef7a52 to your computer and use it in GitHub Desktop.
const {Cc, Ci, Cu, Cr} = require("chrome");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
var observer = {
QueryInterface: XPCOMUtils.generateQI([
Ci.nsIObserver,
Ci.nsISupportsWeakReference
]),
observe: function(subject, topic, data) {
if (topic == "http-on-modify-request" && subject instanceof Ci.nsIHttpChannel) {
var channel = subject.QueryInterface(Ci.nsIHttpChannel);
var requestUrl = channel.originalURI.spec;
if ("WE CHECK THE PATTERN HERE AGAINST $requestUrl") {
channel.cancel(Cr.NS_BINDING_ABORTED);
}
}
}
};
Services.obs.addObserver(observer, "http-on-modify-request", true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment