1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00
This commit is contained in:
gorhill 2015-11-08 00:31:49 -05:00
parent 35474f0146
commit 1c6d969ccb
2 changed files with 46 additions and 38 deletions

View File

@ -72,8 +72,7 @@ function startup(data/*, reason*/) {
// Do not test against `loading`: it does appear `readyState` could be
// undefined if looked up too early.
if ( !hiddenDoc ||
hiddenDoc.readyState !== 'interactive' && hiddenDoc.readyState !== 'complete' ) {
if ( !hiddenDoc || hiddenDoc.readyState !== 'complete' ) {
return false;
}

View File

@ -1233,10 +1233,7 @@ var tabWatcher = (function() {
// https://github.com/gorhill/uBlock/issues/906
// This might have been the cause. Will see.
if (
document.readyState !== 'interactive' &&
document.readyState !== 'complete'
) {
if ( document.readyState !== 'complete' ) {
attachToTabBrowserLater({ window: window, tryCount: tryCount });
return;
}
@ -3111,7 +3108,8 @@ vAPI.contextMenu.displayMenuItem = function({target}) {
/******************************************************************************/
vAPI.contextMenu.register = function(doc) {
vAPI.contextMenu.register = (function() {
var register = function(doc) {
if ( !this.menuItemId ) {
return;
}
@ -3147,7 +3145,18 @@ vAPI.contextMenu.register = function(doc) {
menuitem.addEventListener('command', this.onCommand);
contextMenu.addEventListener('popupshowing', this.displayMenuItem);
contextMenu.insertBefore(menuitem, doc.getElementById('inspect-separator'));
};
};
var registerSafely = function(doc) {
if ( doc.readyState !== 'complete' ) {
vAPI.setTimeout(registerSafely.bind(this, doc), 200);
} else {
register.call(this, doc);
}
};
return registerSafely;
})();
/******************************************************************************/