-
Notifications
You must be signed in to change notification settings - Fork 435
Style injection? #161
Comments
Never mind, your comment was mangled due to Github's markdown, I added proper escape code. This filter is injected when there is a DOM element which matches Edit1: This is a filter present in EasyList: Edit2: For the record: Adblock Plus injects the same rule in everypage unconditionally (along with 14,000+ others). uBlock injects only when there is a DOM element which matches |
Why is this injected for every page with a |
It's explained above... Injecting in every page with
Because no code is taken from ABP, it's written from scratch. |
But why is it injected for |
Because a dictionary is used to find matching cosmetic filters: the first 8 characters of the URL are used to lookup an entry in the dictionary. I chose to use 8 characters after analyzing the distribution of such filters in EasyList. More characters would cause too many of that kind of filters to end up in the high-high generic category, the most expensive in term of CPU. Less character would lead to even lower granularity, i.e. injecting more unrelated cosmetic filters. I am not going to pick a less efficient implementation of such cosmetic filters because of the word |
How about, after it finds a match on the shortened filter, it runs a check on the whole filter, so we don't get reduced selector performance on the live page? That won't reduce performance for the 99.9% of short filters that don't match, and it will increase CSS performance / DOM cleanliness by not injecting a rule for false positives. |
How did you conclude of a "reduced selector performance"? You have a benchmark? If there is was performance gain, I would do it. But there is none. This is the cosmetic filters which end up in the
So you have five true positives for one false positive. This means in the big picture that finer grained injection in the case of high-medium generics is likely to not be a net benefit CPU-wise. Note that these high-medium generics are as a rule injected at the same time of other CSS styles, so not injecting Your solution would require that all the above entry be checked against maybe all the URLs matching Having ideas about implementation is easy, validating them through real working prototypes is however the harder part. |
Just for a bit of perspective re "DOM cleanliness", in the above exemple, I used this page, and uBlock injected a grand total of 20 CSS selectors. With the same filter lists, ABP injected 19,386 CSS selectors. This means uBlock injected 20 / 19,386 => 0.1% of what ABP injects. I say uBlock is not doing bad re. DOM cleanliness. I am open to improve, but that will be on the basis of real data from benchmarking, just like I have been doing so far. |
On the subject of DOM cleanliness, why not put the style in a shadow root? |
Open an issue, I will look into this in more details, I would want to check first cost or benefit mem and cpu-wise, if any. I suppose not being in plain view of other javascript code is an advantage, as this would prevent uBlock's injected style tags from being tampered with by external js code. |
Hi, sorry to bump an old topic, but I just noticed the same thing on my own site:
From what I can guess, this is the result of matching |
EasyList is 3rd-party to this project, you need to contact maintainers of EasyList: https://forums.lanik.us/index.php |
By the way, I used to identify the |
I just saw this injected into a blank page. There were no hyperlinks at all on my page, never mind one that started with |
@mnpenner Any reason to not provide the URL? |
@gorhill Yes. It occurred on a POST on a page I was debugging, after I got a white screen of death. Not something shareable. I'm not quite sure what you're getting at with those source code links. Are you suggesting the filters were cached for domain? If so, that would explain it. I don't doubt there were facebook links on other pages. |
Cosmetic filters for a site are cached as soon as they are used on at least one page of that site (site = hostname in URL). The cached cosmetic filters for a site are injected on all pages of that site -- this allows to inject CSS style rules before the page loads. So if there was one single page on the site for which |
@hmemcpy I would be one of those devs that found it in the DOM inspector. I'll be honest, I thought it was something nefarious injected either server-side or at a browser level... glad to see it's innocuous. |
It looks like this doesn't happen any more. Has this been tightened up? |
+1 for the suggestion to relax this on |
Another dev who just found it in Google Chrome devtools, but I've made a list of things I don't like and I want to change on this behavior: What's wrong with that?
more in #1460 |
I'm having the same issue here:
appearing when I save the source of a webpage in google chrome. |
Sorry to come back to this issue, but inserting inline-styles is a bad idea for websites that have CSP policies activated and refusing inline styles. See https://github.com/nico3333fr/CSP-useful/blob/master/csp-wtf/README.md#ublock-and-faceporn-yes for example. |
I have the same problem |
This code gets injected into the head of every page....
..Why is this happening?
Ignore the " "
The text was updated successfully, but these errors were encountered: