I am looking for a way to add fonts to the whitelist that pages can use in Chrome. In Firefox, I would simply turn off Allow Pages to choose my own fonts, not my settings above in the content settings, but Chrome seems to really want web designers to force us to ugly and often unreadable fonts.
I don’t want to use the * { font-family: sans; }
Stylish style because I want to keep sans (or serif) and monospace sections, and web designers who are crazy as they are usually keep the ones at the end font-family
.
I did my research and I still can’t figure out how to do this using the Chrome extension API.
I considered intercepting requests for CSS files and changing them in response, but this is not possible using the current API.
I could also traverse the DOM tree, check the CSS on each node and replace it accordingly, but it's expensive. Moreover, this will not work for pages that create content from JavaScript. So I would have to use MutationObserver
, and that would be too expensive.
If I could somehow read the CSS files that the current tab uses, I could collect the rules with the style font-family
and inject the corresponding element <style>
into the page through the content script. But I could not find a way to read these CSS files through the current API. (I would also need to read the rules <style>
embedded in HTML, but this is doable).
-, , () SSL.
fontconfig. Arial, ( ) CSS-.
API Chrome? ? , ?
, JavaScript. . , .
wOxxOm document.styleSheets
- , , all! , Chrome CSSStyleSheet#cssRules
null
, https://code.google.com/p/chromium/issues/detail?id=45786. _
(, , GitHub , ).
2
wOxxOm, - ( , ), https://chrome.google.com/webstore/detail/disable-web-fonts/olmabeadgbpmhllgdkemfdnmkngkbkeg. . fontconfig.
, , - https://code.google.com/p/chromium/issues/detail?id=173207.
3
( ) https://chrome.google.com/webstore/detail/font-blocker/knpgaobajhnhgkhhoopjepghknapnikl. , , . , , -, Chrome (. ).