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

cosmetic filters in about:blank iframe #688

Closed
4 of 8 tasks
krystian3w opened this issue Jul 30, 2019 · 38 comments
Closed
4 of 8 tasks

cosmetic filters in about:blank iframe #688

krystian3w opened this issue Jul 30, 2019 · 38 comments
Labels
bug Something isn't working

Comments

@krystian3w
Copy link

krystian3w commented Jul 30, 2019

Apester - Interactive content

Prerequisites

  • I verified that this is not a filter issue
  • This is not a support issue or a question
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue
    • Your issue may already be reported.
  • I tried to reproduce the issue when...
    • uBlock Origin is the only extension
    • uBlock Origin with default lists/settings
    • using a new, unmodified browser profile
  • I am running the latest version of uBlock Origin
  • I checked the documentation to understand that the issue I report is not a normal behavior

Description

How block social in iframes now?

obraz

A specific URL where the issue occurs

https://itsfoss.com/end-of-floppy-disk-in-linux/

old metods down...:

apester.com,itsfoss.com##[class^="StyledShareProviderButtons"].ProviderIcons, [class^="StyledShareProviderButtons"].ProvidersText

I no prefere AdGuard Annoyance filter:

||apester.com^$third-party

Steps to reproduce

@mapx-
Copy link

mapx- commented Jul 30, 2019

I get no such stuff, however you already have a working filter (adguard one)

@mapx- mapx- closed this as completed Jul 30, 2019
@gwarser
Copy link

gwarser commented Jul 30, 2019

StyledShareProviderButton - without 's' at the end. wait a sec.

@mapx- its in the quiz at the end of article


about:blank iframe

@krystian3w
Copy link
Author

I try block ony 3 elements no all widget.

@mapx-
Copy link

mapx- commented Jul 30, 2019

||images.apester.com/user-images*.gif$image,domain=itsfoss.com

@liamengland1
Copy link

That will block other assets used by the iframe, how about ||images.apester.com/user-images%2F*%2F*.gif

Facebook icon: https://images.apester.com/user-images%2Fee%2Feebc3aaa9ad3157935316990e7547c67.gif
Twitter icon: https://images.apester.com/user-images%2Fb8%2Fb81daaab56b92112c7d1cae2a256c249.gif

@krystian3w

This comment has been minimized.

@mapx- mapx- reopened this Jul 30, 2019
@uBlock-user
Copy link
Contributor

uBlock-user commented Aug 2, 2019

I no prefere AdGuard Annoyance filter:

what's wrong with ||apester.com^$third-party ?

@krystian3w
Copy link
Author

Remove all plugin form site. In the past possible remove 3 elements form last "slide".

Now only two with network filter if names of files are stable.

@gwarser
Copy link

gwarser commented Aug 2, 2019

@gorhill how to cosmetically hide elements in about:blank iframe?

In this case:

  • open https://itsfoss.com/end-of-floppy-disk-in-linux/
  • scroll to the end of article
  • finish quiz or click on the arrow in frame top right corner
  • try hiding social icons and subtitle

@gorhill
Copy link
Member

gorhill commented Aug 2, 2019

I would need to fix uBO's code to use match_about_blank and further add code to lookup context from the first ancestor window which is not about:blank.

@krystian3w

This comment has been minimized.

@mapx- mapx- transferred this issue from uBlockOrigin/uAssets Aug 2, 2019
@mapx- mapx- changed the title Apester - Interactive content [cosmetic filters in about:blank iframe] Apester - Interactive content Aug 2, 2019
@mapx- mapx- added the something to address something to address label Aug 2, 2019
@mapx-
Copy link

mapx- commented Aug 2, 2019

@gorhill
how to cosmetically hide elements in about:blank iframe moved here (uBlock issues)

@krystian3w krystian3w changed the title [cosmetic filters in about:blank iframe] Apester - Interactive content cosmetic filters in about:blank iframe Aug 2, 2019
@uBlock-user uBlock-user added bug Something isn't working and removed something to address something to address labels Aug 28, 2019
gorhill added a commit to gorhill/uBlock that referenced this issue Jul 19, 2020
Related issues:
- uBlockOrigin/uBlock-issues#688
- uBlockOrigin/uBlock-issues#1164

`match_about_blank` is now used for content scripts and
user styles.
@uBlock-user uBlock-user added the fixed issue has been addressed label Jul 24, 2020
@gwarser
Copy link

gwarser commented Jul 24, 2020

This still does not work in quiz frame on https://itsfoss.com/end-of-floppy-disk-in-linux/,

  • open https://itsfoss.com/end-of-floppy-disk-in-linux/
  • scroll to the end of article
  • click on the arrow in frame top right corner
  • try hiding social icons and subtitle

@gorhill
Copy link
Member

gorhill commented Jul 24, 2020

But that is just gorhill/uBlock#1744?

@gwarser
Copy link

gwarser commented Jul 24, 2020

I tried manually adding:

itsfoss.com##.shareProviderButton
##.shareProviderButton
itsfoss.com##.share-providers-button
##.share-providers-button
itsfoss.com##.shareOverlay
##.shareOverlay

@uBlock-user uBlock-user reopened this Jul 24, 2020
gorhill added a commit to gorhill/uBlock that referenced this issue Jul 24, 2020
Related issue:
- uBlockOrigin/uBlock-issues#688

`about:` frames need to lookup and use the inherited
origin from their parent browsing context for proper
lookup of cosmetic filters.
@gorhill
Copy link
Member

gorhill commented Jul 24, 2020

Specific cosmetic filters should work with latest commit, but there is still an issue which I need to investigate, the mutation observer does not work in the about:blank frame in test case above. This means generic cosmetic filters and logging cosmetic filters does not work in the above test case. I don't know the reason for why the mutation observer does not work.

I found AdGuard seems to suffer the same issue as well -- it does not report the cosmetic filters in its logger for the test case above.

@krystian3w

This comment has been minimized.

@gorhill

This comment has been minimized.

@gorhill
Copy link
Member

gorhill commented Jul 25, 2020

I don't know the reason for why the mutation observer does not work.

The page uses document.open() to create a new document in the iframe -- that would be the reason for the mutation observer ceasing to work.

@krystian3w
Copy link
Author

#688 (comment)

but for some reason Google bar need CSS - This could be another threat that someone would do a similar advertising mechanism and you would have to start using more scriptlets.

@gorhill
Copy link
Member

gorhill commented Jul 25, 2020

but for some reason Google bar need CSS

Please open a distinct issue for this with repro steps (I don't know what is "Google bar"), the issue here is for about:blank.

@krystian3w

This comment has been minimized.

@gwarser
Copy link

gwarser commented Nov 21, 2020

It seems to be fixed by gorhill/uBlock@8d3c491

Can you check?

Generic filters still don't work.

@raszpl
Copy link

raszpl commented Dec 11, 2020

I was reading https://palant.info/2020/12/10/how-anti-fingerprinting-extensions-tend-to-make-fingerprinting-easier/ and came upon an example

console.log(screen.width);
Object.defineProperty(Screen.prototype, "width", {value: 1280});
console.log(screen.width);
var frame = document.createElement("iframe");
document.body.appendChild(frame);
console.log(screen.width, frame.contentWindow.screen.width);

producing:

1920
1280
1280 1920

in gorhill/uBlock#1740 I found @gorhill
":[1] It's a solution I have considered in the past: to make the content scripts able to inject themselves into source-less iframes. This is already sort-of done by injected scriptlets, they will propagate to source-less child frames."

Does this mean scriptlets should be injecting into about:blank iFrames? Has this worked in the past? I cant get this to work. I can see in Chrome devtools about:blank iFrame context has uBO listed as injected, but my scriptlet is not executed.

/// myscriptlet.js 
Object.defineProperty(Screen.prototype, "width", {value: 1280});

defined at userResourcesLocation, My filters: "*##+js(myscriptlet)".

console.log(screen.width);
var frame = document.createElement("iframe");
document.body.appendChild(frame);
console.log(screen.width, frame.contentWindow.screen.width);

produces:

1280
1280 1920

suggesting myscriptlet is injected into the main page, but not the about:blank iFrame

@gorhill
Copy link
Member

gorhill commented Dec 11, 2020

Your scriptlet can't be injected at document_start, so there will always be a delay before your scriptlet code execute. You will have to check the value later, not immediately after inserting the iframe.

@raszpl
Copy link

raszpl commented Dec 12, 2020

I watched a movie, came back and results are still the same. I tested old chrome 77 with uBO v1.30.6 just to be sure, still same result. I tried something different

var frame = document.createElement("iframe");
var html = '<body><script>alert(1)</script>Content</body>';
frame.src = 'data:text/html;charset=utf-8,' + encodeURI(html);
document.body.appendChild(frame)

uBlock didnt inject in this iframe at all (going by Chrome devtools console "javascript context" dropdown), not sure if its meant to since I googled up whatwg/html#1753. It did inject into srcdoc variant

var frame = document.createElement("iframe");
frame.srcdoc = '<body><script>alert(1)</script>Content</body>'
document.body.appendChild(frame)

still no scriptlet injections.

One of the scriptlets I use for a long time starts with
console.log("something here ",location.href)
and I have a vague recollection of seeing it report about:blank as the source while debugging some popup happy websites long time ago, but I cant find/replicate it now. My question is - is my assumption that scriptlets are meant to be injected into about: iframes correct?

@gwarser
Copy link

gwarser commented Dec 12, 2020

@raszpl are you using this filter with wildcard (specific-generic) *##+js(myscriptlet)?

Does not work on localhost:8080 for some reason.

I also tried with following filters and injecting is not reported in logger on localhost:8080, but works on example.com. Version with localhost instead of * works fine.

*##+js(test)
*##+js(nobab)

test -> https://gist.githubusercontent.com/gwarser/63ab7869174bb2f0880361bf9719bd0b/raw/6bd71b1feba0498221a7abd3c4a17e39febbc42d/test.js

[source not relevant]

@gorhill
Copy link
Member

gorhill commented Dec 12, 2020

Can't inject in data: or srcdoc` iframe, this is a known extension API limitation.

@gwarser
Copy link

gwarser commented Dec 13, 2020

Specific-generic scriptlets do not work on "TLD domain only" websites, localhost for example, but there are few in the wild - http://pn/? I'm sure there are more. scriptletDB.retrieve fails to retrieve any scriptlet? hostnameToSlotIdMap.get() called with empty string instead of *?


Fixed in gorhill/uBlock@b22cf24

gorhill added a commit to gorhill/uBlock that referenced this issue Dec 14, 2020
@raszpl
Copy link

raszpl commented Dec 18, 2020

@gwarser

but works on example.com

are you saying your *##+js(test) reports "about:blank" after

var frame = document.createElement("iframe");
document.body.appendChild(frame);

?

@gwarser
Copy link

gwarser commented Dec 18, 2020

I did not checked embedded contexts. *##+js... scriptlet was not injected at all in my test on localhost.

@gwarser
Copy link

gwarser commented Dec 18, 2020

This does not work at all in Chrome? (Is this about this Chrome bug [edit: new way of injecting into blank frames] I cannot find now?)

Testing *##+js(test) on https://gistcdn.rawgit.org/gwarser/dcea28c77bf2f6cb1c77229a92509b33/be97d8483cb0fdbb69af87b4295b905722685b98/frames.html

Firefox 86: uBO rc2 logger shows three injections and console logs page, blank and srcdoc.

Chrome 87.0.4280.88: only one injection, only page address logged.

@gorhill
Copy link
Member

gorhill commented Dec 18, 2020

Is this about this Chrome bug I cannot find now?

No, scriptlets are injected differently in Chromium, at webNavigation.onCommitted time (code), and the information received in such case is not the effective URL, it's just about:blank, in which case uBO bails out.

gorhill added a commit to gorhill/uBlock that referenced this issue Dec 18, 2020
This is an issue in uBO affecting only Chromium-based browsers.

Related feedback:
uBlockOrigin/uBlock-issues#688 (comment)
@gwarser
Copy link

gwarser commented Dec 18, 2020

Ok, now only rawgit.org##+js(test) is not injected into srcdoc but specific-generic works fine.

It's after gorhill/uBlock@8d3c491, so rather expected.

@raszpl
Copy link

raszpl commented Dec 19, 2020

@gwarser

This does not work at all in Chrome?

Thank you for confirmation, I was beginning to think I was going crazy.

and gorhill/uBlock@990cff5 thank you @gorhill for quick fix :o
I didnt even know about the test builds :( checking v1.31.3rc3 now:
https://gistcdn.rawgit.org/gwarser/dcea28c77bf2f6cb1c77229a92509b33/be97d8483cb0fdbb69af87b4295b905722685b98/frames.html

*##+js(myscriptlet)

myscriptlet  https://gistcdn.rawgit.org/gwars...05722685b98/frames.html
myscriptlet  about:blank
myscriptlet  about:srcdoc

Works great now.

@gorhill
Copy link
Member

gorhill commented Dec 19, 2020

not injected into srcdoc but specific-generic works fine

Maybe I can come up with a fix for this in next dev cycle.

@raszpl
Copy link

raszpl commented Dec 19, 2020

srcdoc did work for me
Edit: oh, I get it. *##+js... works for srcdoc , but targeted filters wont fire. nvm

@gorhill
Copy link
Member

gorhill commented Nov 19, 2022

Closing as obsolete. Fixes were made and it's unclear if and what are the other issues left if any -- too many comments about various other stuff. Open clearly detailed and well narrow issues if there is still something to fix, and these have to be issues with real world implications.

@gorhill gorhill closed this as completed Nov 19, 2022
@krystian3w krystian3w changed the title cosmetic filters in about:blank iframe cosmetic filters in about:blank iframe Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants