mirror of https://github.com/gorhill/uBlock.git
Harden scriptlet injections
This commit make it so scriptlet injections will occur at the earliest possible time on all platform. This should also fix the case reported at: - https://www.reddit.com/r/uBlockOrigin/comments/ye6abt/ Which is caused by the fact that there is no webNavigation events being fired by the browser. In such case, the changes here will make it so that uBO will detect that the scriptlet were not injected and will inject them at main content script injection time.
This commit is contained in:
parent
2d3d57fbc8
commit
bccd5a0264
|
@ -19,6 +19,8 @@
|
|||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* globals browser */
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -149,7 +151,6 @@ const µBlock = { // jshint ignore:line
|
|||
privacySettingsSupported: vAPI.browserSettings instanceof Object,
|
||||
cloudStorageSupported: vAPI.cloud instanceof Object,
|
||||
canFilterResponseData: typeof browser.webRequest.filterResponseData === 'function',
|
||||
canInjectScriptletsNow: vAPI.webextFlavor.soup.has('chromium'),
|
||||
|
||||
// https://github.com/chrisaljoudi/uBlock/issues/180
|
||||
// Whitelist directives need to be loaded once the PSL is available
|
||||
|
|
|
@ -1362,6 +1362,9 @@ vAPI.DOMFilterer = class {
|
|||
vAPI.messaging.send('contentscript', {
|
||||
what: 'retrieveContentScriptParameters',
|
||||
url: vAPI.effectiveSelf.location.href,
|
||||
scriptletsInjected:
|
||||
typeof self.uBO_scriptletsInjected === 'boolean' &&
|
||||
self.uBO_scriptletsInjected,
|
||||
}).then(response => {
|
||||
bootstrapPhase1(response);
|
||||
});
|
||||
|
|
|
@ -773,10 +773,7 @@ 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 (
|
||||
µb.canInjectScriptletsNow === false ||
|
||||
isNetworkURI(sender.frameURL) === false
|
||||
) {
|
||||
if ( request.scriptletsInjected !== true ) {
|
||||
scriptletFilteringEngine.injectNow(request);
|
||||
}
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ const contentscriptCode = (( ) => {
|
|||
) {
|
||||
return;
|
||||
}
|
||||
self.uBO_scriptletsInjected = true;
|
||||
const injectScriptlets = function(d) {
|
||||
let script;
|
||||
try {
|
||||
|
|
|
@ -41,7 +41,6 @@ import {
|
|||
import {
|
||||
domainFromHostname,
|
||||
hostnameFromURI,
|
||||
isNetworkURI,
|
||||
originFromURI,
|
||||
} from './uri-utils.js';
|
||||
|
||||
|
@ -930,11 +929,7 @@ vAPI.Tabs = class extends vAPI.Tabs {
|
|||
const pageStore = µb.pageStoreFromTabId(tabId);
|
||||
if ( pageStore === null ) { return; }
|
||||
pageStore.setFrameURL(details);
|
||||
if (
|
||||
µb.canInjectScriptletsNow &&
|
||||
isNetworkURI(url) &&
|
||||
pageStore.getNetFilteringSwitch()
|
||||
) {
|
||||
if ( pageStore.getNetFilteringSwitch() ) {
|
||||
scriptletFilteringEngine.injectNow(details);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue