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.
  • Loading branch information
gorhill committed May 19, 2020
1 parent 5229e0c commit 9f7e5b6
Show file tree
Hide file tree
Showing 4 changed files with 12 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/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const µBlock = (( ) => { // jshint ignore:line
suspendTabsUntilReady: 'unset',
uiPopupConfig: 'undocumented',
uiFlavor: 'unset',
uiStyles: 'unset',
updateAssetBypassBrowserCache: false,
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 @@ -159,6 +159,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' }).then(response => {
if ( typeof response !== 'string' || response === 'unset' ) { return; }
document.body.style.cssText = response;
});
}

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

0 comments on commit 9f7e5b6

Please sign in to comment.