1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-15 07:22:28 +02:00

Fix case of scriptlet injection not working about: frames

This is an issue in uBO affecting only Chromium-based browsers.

Related feedback:
https://github.com/uBlockOrigin/uBlock-issues/issues/688#issuecomment-748179731
This commit is contained in:
Raymond Hill 2020-12-18 12:07:08 -05:00
parent 2867ae175f
commit 990cff576d
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
3 changed files with 13 additions and 5 deletions

View File

@ -627,7 +627,13 @@ const retrieveContentScriptParameters = function(sender, request) {
response.specificCosmeticFilters =
µb.cosmeticFilteringEngine.retrieveSpecificSelectors(request, response);
if ( µb.canInjectScriptletsNow === false ) {
// 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 ||
µb.URI.isNetworkURI(sender.frameURL) === false
) {
response.scriptlets = µb.scriptletFilteringEngine.retrieve(request);
}

View File

@ -377,7 +377,6 @@
api.injectNow = function(details) {
if ( typeof details.frameId !== 'number' ) { return; }
if ( µb.URI.isNetworkURI(details.url) === false ) { return; }
const request = {
tabId: details.tabId,
frameId: details.frameId,

View File

@ -868,7 +868,10 @@ vAPI.Tabs = class extends vAPI.Tabs {
// properly setup if network requests are fired from within the tab.
// Example: Chromium + case #6 at
// http://raymondhill.net/ublock/popup.html
// https://github.com/uBlockOrigin/uBlock-issues/issues/688#issuecomment-748179731
// For non-network URIs, defer scriptlet injection to content script. The
// reason for this is that we need the effective URL and this information
// is not available at this point.
onNavigation(details) {
super.onNavigation(details);
const µb = µBlock;
@ -879,8 +882,8 @@ vAPI.Tabs = class extends vAPI.Tabs {
pageStore.journalAddRootFrame('committed', details.url);
}
}
if ( µb.canInjectScriptletsNow ) {
let pageStore = µb.pageStoreFromTabId(details.tabId);
if ( µb.canInjectScriptletsNow && µb.URI.isNetworkURI(details.url) ) {
const pageStore = µb.pageStoreFromTabId(details.tabId);
if ( pageStore !== null && pageStore.getNetFilteringSwitch() ) {
µb.scriptletFilteringEngine.injectNow(details);
}