1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-04 08:37:11 +02: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) { sandbox.injectScript = function(script) {
var svc = Services; var svc = Services;
if ( svc !== undefined ) { // Sandbox appears void.
svc.scriptloader.loadSubScript(script, sandbox); // I've seen this happens, need to investigate why.
} else { if ( svc === undefined ) {
// Sandbox appears void. return;
// I've seen this happens, need to investigate why.
} }
svc.scriptloader.loadSubScript(script, sandbox);
}; };
// The goal is to have content scripts removed from web pages. This // The goal is to have content scripts removed from web pages. This

View File

@ -116,10 +116,20 @@ vAPI.messaging = {
return; return;
} }
var details = msg.details; var details = msg.details;
if ( !details.allFrames && window !== window.top ) { if ( details.allFrames !== true && window !== window.top ) {
return; 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; return;
} }
if ( msg.cmd === 'shutdownSandbox' ) { if ( msg.cmd === 'shutdownSandbox' ) {