1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-22 18:32:45 +01:00
This commit is contained in:
gorhill 2015-10-28 09:35:13 -04:00
parent 7483e7b306
commit 99c4dfffc2
2 changed files with 17 additions and 7 deletions

View File

@ -258,12 +258,12 @@ var contentObserver = {
sandbox.injectScript = function(script) {
var svc = Services;
if ( svc !== undefined ) {
svc.scriptloader.loadSubScript(script, sandbox);
} else {
// Sandbox appears void.
// I've seen this happens, need to investigate why.
// Sandbox appears void.
// I've seen this happens, need to investigate why.
if ( svc === undefined ) {
return;
}
svc.scriptloader.loadSubScript(script, sandbox);
};
// The goal is to have content scripts removed from web pages. This

View File

@ -116,10 +116,20 @@ vAPI.messaging = {
return;
}
var details = msg.details;
if ( !details.allFrames && window !== window.top ) {
if ( details.allFrames !== true && window !== window.top ) {
return;
}
self.injectScript(details.file);
// https://github.com/gorhill/uBlock/issues/876
// Enforce `details.runAt`. Default to `document_end`.
if ( details.runAt === 'document_start' || document.readyState !== 'loading' ) {
self.injectScript(details.file);
return;
}
var injectScriptDelayed = function() {
document.removeEventListener('DOMContentLoaded', injectScriptDelayed);
self.injectScript(details.file);
};
document.addEventListener('DOMContentLoaded', injectScriptDelayed);
return;
}
if ( msg.cmd === 'shutdownSandbox' ) {