Skip to content

Commit

Permalink
Add new advanced setting: uiStyles
Browse files Browse the repository at this point in the history
Default to `unset`.

To allow users to bypass uBO's default CSS styles in
case they are causing issues to specific users. It is
the responsibility of the user to ensure the value of
`uiStyles` contains valid CSS property declarations.
uBO will assign the value to `document.body.style.cssText`.

Related issue:
- uBlockOrigin/uBlock-issues#1044

For example, in the case of the issue above, one could
set `uiStyles` to `font-family: sans-serif` to force uBO
to the system font for its user interface.

Co-authored-by:  gorhill <[email protected]>
  • Loading branch information
hawkeye116477 and gorhill committed Nov 4, 2020
1 parent 930038c commit 013b64a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/css/dashboard-common.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ body > div.body {
}
h2, h3 {
margin: 1em 0;
font-family: sans-serif;
}
h2 {
font-size: 18px;
Expand Down
1 change: 1 addition & 0 deletions src/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

<script src="js/vapi.js"></script>
<script src="js/vapi-common.js"></script>
<script src="js/vapi-client.js"></script>
<script src="js/udom.js"></script>
<script src="js/i18n.js"></script>
<script src="js/dashboard.js"></script>
Expand Down
1 change: 1 addition & 0 deletions src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var µBlock = (function() { // jshint ignore:line
requestJournalProcessPeriod: 1000,
suspendTabsUntilReady: false,
toolbarButtonForceTypeMenu: false,
uiStyles: 'unset',
userResourcesLocation: 'unset'
};

Expand Down
4 changes: 4 additions & 0 deletions src/js/messaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ const onMessage = function(request, sender, callback) {
µb.toggleHostnameSwitch(request);
break;

case 'uiStyles':
response = µb.hiddenSettings.uiStyles;
break;

case 'userSettings':
response = µb.changeUserSettings(request.name, request.value);
break;
Expand Down
7 changes: 7 additions & 0 deletions src/js/udom.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ DOMListFactory.nodeFromSelector = function(selector) {
if ( window.matchMedia('(prefers-color-scheme: dark)').matches ) {
root.classList.add('dark');
}

// https://github.com/uBlockOrigin/uBlock-issues/issues/1044
// Offer the possibility to bypass uBO's default styling
vAPI.messaging.send('uDom', { what: 'uiStyles' }, response => {
if ( typeof response !== 'string' || response === 'unset' ) { return; }
document.body.style.cssText = response;
});
}

/******************************************************************************/
Expand Down

0 comments on commit 013b64a

Please sign in to comment.