Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filters not being injected in dynamically created iframes #1860

Closed
mneunomne opened this issue Jun 2, 2021 · 8 comments
Closed

Filters not being injected in dynamically created iframes #1860

mneunomne opened this issue Jun 2, 2021 · 8 comments

Comments

@mneunomne
Copy link
Collaborator

mneunomne commented Jun 2, 2021

It seems that we are not being able to add all the filters we need inside empty src iframes.

This is a theoretical test case. But it seems to be not hiding on Chrome and on Firefox the ad is not even rendered for some reason (might be an issue with the test script).

I suspect this is related to this issue: #1844

@mneunomne
Copy link
Collaborator Author

This should be dealing with this in theory, but this line is never reached when we need it to be.

if ( result ) {
let selectors = result.injected;
if ( typeof selectors === 'string' && selectors.length !== 0 ) {
//ADN tmp fix: hiding - local iframe without src
const isSpecialLocalIframes = (location.href=="about:blank" || location.href=="") && (window.self !== window.top)
domFilterer.addCSSRule(
selectors,
vAPI.hideStyle,
{ mustInject: isSpecialLocalIframes ? true : false } // ADN
);

because result is null.
if ( ids.length !== 0 || classes.length !== 0 ) {
messaging.send('contentscript', {
what: 'retrieveGenericCosmeticSelectors',
hostname,
ids,
classes,
exceptions: domFilterer.exceptions,
cost: surveyCost,
}).then(response => {
surveyPhase3(response);
});
} else {
surveyPhase3(null);
}

@mneunomne
Copy link
Collaborator Author

We need a test case to confirm this behavior:

2. IFrames

If an iFrame matches a cosmetic selector and has a valid 'src' attribute, processIFrame() is called. If the iFrame's 'src' and parent page have the same origin, processIFrame() selects all images within the iFrame and handles them as above. If the iFrame is cross-domain, however, we will not be able to access its contents due to "Same Origin" security restrictions. In this case, we may need to manually create a new cosmetic filter for the element of interest inside the the iFrame (and add it to adnauseam.txt).
If, on Chromium-based browsers, an iFrame is dynamically-generated, the primeLocalIFrame() function attempts to inject the usual contentscripts into the iFrame (this will happen automatically on Firefox). If the injection is successful, a console message in the addon console will read as follows:
[INJECT] Dynamic-iFrame...
You may inspect the pageStore object to find more information about the iFrame.

@mneunomne
Copy link
Collaborator Author

Some info can be found in this discussion as well: gorhill#1740

@dhowe
Copy link
Owner

dhowe commented Jun 3, 2021

Some info can be found in this discussion as well: gorhill#1740

glad you found this one :)

see also: uBlockOrigin/uBlock-issues#688

I'm going to rename this to 'dynamically-created', unless there is some other case for empty src

@dhowe dhowe changed the title Filters not being injected in iframes with blank src Filters not being injected in dynamically created iframes Jun 3, 2021
@mneunomne
Copy link
Collaborator Author

It seems that indeed this seems to be happening. As you can see uBlock injected the content script in the about:blank iframe windows, while Adn did not.

uBlock Origin:
French Open 2021 Stream Free - Google Chrome 09 06 2021 11_07_26

Adnauseam:
Windows 10 Screenshot - So erstellen Sie Screenshots in Windows 10 - IONOS - Google Chrome 09 06 2021 11_07_12

@mneunomne
Copy link
Collaborator Author

mneunomne commented Jun 14, 2021

@dhowe found another example:

http://mazystreams.xyz/event/manchester-city-vs-chelsea/s1.php

I can confirm this is happening since when thying to hide the ad above in Adnauseam, doesn't matter how much i add blocking filters even with $important they are not blocked.

I'm adding a high priority since this is the cause of a huge amount of ads appearing with Adnauseam.

Adnauseam, ad frame about:blank with no injected content script:
Mazy Streams _ Stream 1 - Google Chrome 6_14_2021 12_19_47 PM

in uBlock Origin, ad frame about:blank and content script injected.
Mazy Streams _ Stream 1 - Google Chrome 6_14_2021 12_23_21 PM

@mneunomne
Copy link
Collaborator Author

At least in the case of chrome it was suposed to be happening here:

// Also being used by ADN to inject content-scripts into dynamically-created
// iframes, as Chrome does not inject into these by default. This is needed
// because we often can't block the iframe outright, as we need the ads inside.
//
vAPI.onLoadAllCompleted = function(tabId, frameId) { //ADN

@mneunomne
Copy link
Collaborator Author

Tested, closing

dhowe added a commit that referenced this issue Jun 28, 2021
add match_about_blank to root manifest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants