Skip to content

Instantly share code, notes, and snippets.

@xulapp
Created April 3, 2011 14:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xulapp/900437 to your computer and use it in GitHub Desktop.
Save xulapp/900437 to your computer and use it in GitHub Desktop.
document.loadOverlay
// ==uc==
// @include *
// @exclude chrome://browser/content/preferences/preferences.xul
// ==/uc==
(function Bug330458() {
var orgLoadOverlay = document.loadOverlay;
var queue = [];
var loading = false;
function Observer(org) {
this.org = org;
}
Observer.prototype = {
constructor: Observer,
observe: function observe(subject, topic, data) {
try {
if (this.org instanceof Ci.nsIObserver)
this.org.observe(subject, topic, data);
} catch (e) {
Cu.reportError(e);
}
if (topic === 'xul-overlay-merged')
setTimeout(next, 0);
},
QueryInterface: function(iId) {
if(iId.equals(Ci.nsISupports) || iId.equals(Ci.nsIObserver))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
};
function next() {
loading = false;
var args = queue.shift();
if (args)
loadOverlay.apply(document, args);
}
function loadOverlay(url, observer) {
if (loading) {
queue.push([url, observer]);
return;
}
loading = true;
orgLoadOverlay.call(this, url, new Observer(observer));
}
document.loadOverlay = loadOverlay;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment