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

[Firefox] Use nsIDOMWindowUtils.loadSheetUsingURIString() to harden declarative cosmetic filters #1952

Closed
gorhill opened this issue Aug 31, 2016 · 2 comments

Comments

@gorhill
Copy link
Owner

gorhill commented Aug 31, 2016

Firefox's API support user stylesheets, which have precedence over web sites' styles, even inline styles.

Investigate using Firefox's user stylesheets to prevent websites from overriding uBO's cosmetic filters.

Test case from uBlockOrigin/uAssets#123:

Result for Firefox:

  • The click bait ads below the video are visible.
  • The click bait ads are not visible with ABP -- and the placeholder is properly collapsed.

Result for Chromium:

  • The click bait ads are not visible, but the placeholder is not properly collapsed.
    • Because uBO also hides using shadow root on the node. Probably an extra :style filter would solve the placeholder issue.
  • The click bait ads are visible with ABP.

Expected result:

  • The click bait ads are not visible, and no placeholder is left behind.

Notes:

  • In Firefox, when enabling dom.webcomponents.enabled in about:config, the result in Firefox/uBO becomes the same as the result in Chromium/uBO.
@gorhill
Copy link
Owner Author

gorhill commented Aug 31, 2016

This will work for Firefox 36+: https://bugzilla.mozilla.org/show_bug.cgi?id=1089230.

@gorhill gorhill changed the title [Firefox] Investigate using nsIDOMWindowUtils.loadSheetUsingURIString() to harden declarative cosmetic filters [Firefox] Use nsIDOMWindowUtils.loadSheetUsingURIString() to harden declarative cosmetic filters Aug 31, 2016
@gorhill
Copy link
Owner Author

gorhill commented Aug 14, 2017

To @Drugoy from cadeyrn/newtaboverride#3 (comment):

B/s
[...]
Stylish on Chromium-based browsers works this way too. The order in which the browser allows an extension apply the styles - it's details.

Here is a detail for you:

Enter following custom style this in Stylish for raymondhill.net:

.ADBox {
    display: none !important;
}

a

Now visit this page: http://raymondhill.net/ublock/adbox.html.

Result on Chromium with Stylish + custom style above:

a

That's CSS 101: inline style wins over stylesheet styles -- unless the browser supports user stylesheets which actually override inline styles.

For reference, how the page look without Stylish:

a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant