gorhill / uBlock

uBlock Origin - An efficient blocker for Chromium and Firefox. Fast and lean.
GNU General Public License v3.0
44.48k stars 2.99k forks source link

Option to block third-party fonts? #1787

Closed jkleint closed 7 years ago

jkleint commented 8 years ago

Is it possible to block only third-party fonts? I understand many people want to block all remote fonts for security reasons, and that option should stay; however, many websites use fonts hosted on their own domain for icons, and blocking all remote fonts makes these impossible to see (as well as not rendering text in custom fonts, of course).

For example, here is part of the navigation bar from http://www.cnn.com normally (with remote fonts enabled):

cnn-icon-font-unblocked

And here it is with remote fonts blocked:

cnn-icon-font

The magnifying glass icon has been replaced by a box with the hex value of the Unicode character in it. You can test this by checking "Block remote fonts" under "Default Behavior" in the uBlock settings and browsing to cnn.com.

From the uBlock logs, you can see that fonts from the domain cnn.com are being blocked with the no-remote-fonts rule:

font-block-log

This is with uBlock Origin v1.7.6 on Firefox 47.

It would be nice to be able to block third-party fonts to prevent third-party tracking, while still allowing first-party fonts for usability and styling.

As a workaround, you can use Fanboy's Thirdparty Fonts filter list. Lists, of course, require manual curation and have some overhead. It seems like blocking third-party fonts in uBlock would be simple, efficient (making use of information uBlock already has: "is this a font?" "is it from the same origin?"), and could pro-actively provide better tracking protection than lists.

Thanks!

aggat commented 8 years ago

You can uncheck no remote fonts opption and add *$font,third-party to My filters

jkleint commented 7 years ago

Oh, tasty. Thanks!

svenper commented 7 years ago

@aggat's workaround does reduce the risk of third party tracking, but allows fonts that may still be unwanted (e.g. the "CNN" font they use for the rest of the page). I think another possible feature would be to selectively allow icon fonts based on their name / unicode range, but I am not sure how that would be implemented.

ghost commented 6 years ago

You can uncheck no remote fonts option and add *$font,third-party to My filters

Use *$font,third-party,domain=~example.com|~example2.net (two domains) to whitelist domains.

source

ghost commented 6 years ago

@jkleint You shouldn't have closed this issue as an option to only block third-party fonts in uBlock Origin settings (chrome://ublock0/content/dashboard.html#settings.html) would be highly desirable.

xxluke commented 6 years ago

I second that, why should I want to block self-hosted fonts? They aren't ads, in my opinion not annoying (but it's annoying when icons aren't loaded) and I don't get why this is a privacy/security issue.

refriedfood commented 6 years ago

Yes. There are some first party fonts that are so goddamn terrible (especially these "clear types"), the only way to remove them is block the css, but it ruins the entire page. I want to be able to block toplevel domain fonts. Even the block remote fonts in the current version I run (1.13.8) blocks first party custom fonts, causing ascii characters.

Why can't I just block certain fonts that are in the css of the domain? font-family:'Gill Sans MT','Segoe UI' is GOD AWFUL and in order to view the pages that use it, I either have to enable block remote fonts, or uncheck "allow custom fonts" in firefox's settings briefly.

*trying to avoid bloating of addons, etc.

Hrxn commented 6 years ago

Or, run some custom CSS, e.g. with extensions like Stylish etc.?

svenper commented 6 years ago

uBlock Origin is NOT [only] an “ad blocker”: it is a wide-spectrum blocker – which happens to be able to function as a mere “ad blocker”

I.e., we should be able to block anything we want. Some are annoyed by web fonts, others are not.

The reason for not blocking all webfonts is icon fonts conveying important information. (Whether this is good design is another question – it is the current actual state of the web.) The reason for blocking other normal text fonts is that they consume a disproportionate amount of data, often for little benefit, or even actually making the web harder to read and uglier, which of course is subjective, which is why it would be optional.

Doing this with a Stylish script would still download the fonts, but just override them afterwards. uBlock is more powerful and expressive.

First/second/third party block rules are not enough either as many sites host their own copies of third party fonts.

Hrxn commented 6 years ago

Agreed, but better than nothing, when dealing with real issues like legibility etc.

refriedfood commented 6 years ago

The other issue is that I'm perfectly aware that even if they were to make this improvement on uBO, I'd have to upadte my browser which I just don't need nor want to do. So, I just write filters out of the logger and use the chrome\userContent.css method.

eg. m.media-amazon.com/images/G/01/AUIClients/AmazonUIBaseCSS-amazonember*$font & @font-face { font-family: 'Segoe UI'; src: local('Arial'); }

Halibut80 commented 6 years ago

Doing this with a Stylish script would still download the fonts, but just override them afterwards. uBlock is more powerful and expressive.

Hmm? I pretty sure you are wrong.

Open https://twitter.com/ See in console what is font edge-icons-Regular is loaded: Download and install this font to your system (https://abs.twimg.com/a/1510347670/font/edge-icons-Regular.ttf). Create style in Stylish/userContent.css:

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document domain("twitter.com") {

    @font-face {
        font-family: "edgeicons";
        src: local("edge-icons-Regular");
    }

}

Reload page (with cash disabled, of course): no network request to load font is fired.

refriedfood commented 6 years ago

Currently, I open the logger, find the css or font via filtering, and then add the line once I've found the font using the "static filtering" tab. Most of are from fonts.gstatic.com/s/ which can be handled with ||fonts.gstatic.com/s/*$font or ||fonts.googleapis.com/css?family=* And keep the ASCII chars fine, but, some fonts like comfortaa still slip through in style.css which you can easily use the inspector tool in firefox to modify, but that isn't permanent, and there isn't a way to block it in origin that I've found which doesn't get rid of the entire style.css, etc.