mirror of https://github.com/gorhill/uBlock.git
Further ensure scriptlets are actually injected
Related feedback: - https://www.reddit.com/r/uBlockOrigin/comments/ye6abt/ Possibly because the Opera sidebar window is a special case, it appears the scriptlets must be injected at a later time. Use a global isolated window variable to detect whether the scriptlets have really be injected, and ultimately inject them at main content script time when it is found they haven't been injected at that point.
This commit is contained in:
parent
0a55767ea3
commit
d1f8a05d2d
|
@ -1331,7 +1331,8 @@ vAPI.DOMFilterer = class {
|
|||
|
||||
// Library of resources is located at:
|
||||
// https://github.com/gorhill/uBlock/blob/master/assets/ublock/resources.txt
|
||||
if ( scriptlets ) {
|
||||
if ( scriptlets && typeof self.uBO_scriptletsInjected !== 'boolean' ) {
|
||||
self.uBO_scriptletsInjected = true;
|
||||
vAPI.injectScriptlet(document, scriptlets);
|
||||
vAPI.injectedScripts = scriptlets;
|
||||
}
|
||||
|
@ -1362,9 +1363,7 @@ vAPI.DOMFilterer = class {
|
|||
vAPI.messaging.send('contentscript', {
|
||||
what: 'retrieveContentScriptParameters',
|
||||
url: vAPI.effectiveSelf.location.href,
|
||||
scriptletsInjected:
|
||||
typeof self.uBO_scriptletsInjected === 'boolean' &&
|
||||
self.uBO_scriptletsInjected,
|
||||
needScriptlets: typeof self.uBO_scriptletsInjected !== 'boolean',
|
||||
}).then(response => {
|
||||
bootstrapPhase1(response);
|
||||
});
|
||||
|
|
|
@ -773,8 +773,8 @@ const retrieveContentScriptParameters = async function(sender, request) {
|
|||
// https://github.com/uBlockOrigin/uBlock-issues/issues/688#issuecomment-748179731
|
||||
// For non-network URIs, scriptlet injection is deferred to here. The
|
||||
// effective URL is available here in `request.url`.
|
||||
if ( request.scriptletsInjected !== true ) {
|
||||
scriptletFilteringEngine.injectNow(request);
|
||||
if ( request.needScriptlets ) {
|
||||
response.scriptlets = scriptletFilteringEngine.injectNow(request);
|
||||
}
|
||||
|
||||
// https://github.com/NanoMeow/QuickReports/issues/6#issuecomment-414516623
|
||||
|
|
|
@ -432,13 +432,17 @@ scriptletFilteringEngine.injectNow = function(details) {
|
|||
matchAboutBlank: true,
|
||||
runAt: 'document_start',
|
||||
});
|
||||
if ( logEntries === undefined ) { return; }
|
||||
if ( logEntries !== undefined ) {
|
||||
promise.then(results => {
|
||||
if ( Array.isArray(results) === false || results[0] !== 0 ) { return; }
|
||||
if ( Array.isArray(results) === false || results[0] !== 0 ) {
|
||||
return;
|
||||
}
|
||||
for ( const entry of logEntries ) {
|
||||
logOne(entry.tabId, entry.url, entry.token);
|
||||
}
|
||||
});
|
||||
}
|
||||
return scriptlets;
|
||||
};
|
||||
|
||||
scriptletFilteringEngine.toSelfie = function() {
|
||||
|
|
Loading…
Reference in New Issue