Skip to content

Commit 9f7e5b6

Browse files
committed
Add new advanced setting: uiStyles
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.
1 parent 5229e0c commit 9f7e5b6

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

src/css/dashboard-common.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ body > div.body {
88
}
99
h2, h3 {
1010
margin: 1em 0;
11-
font-family: sans-serif;
1211
}
1312
h2 {
1413
font-size: 18px;

src/js/background.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const µBlock = (( ) => { // jshint ignore:line
7474
suspendTabsUntilReady: 'unset',
7575
uiPopupConfig: 'undocumented',
7676
uiFlavor: 'unset',
77+
uiStyles: 'unset',
7778
updateAssetBypassBrowserCache: false,
7879
userResourcesLocation: 'unset',
7980
};

src/js/messaging.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ const onMessage = function(request, sender, callback) {
159159
µb.toggleHostnameSwitch(request);
160160
break;
161161

162+
case 'uiStyles':
163+
response = µb.hiddenSettings.uiStyles;
164+
break;
165+
162166
case 'userSettings':
163167
response = µb.changeUserSettings(request.name, request.value);
164168
break;

src/js/udom.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ DOMListFactory.nodeFromSelector = function(selector) {
105105
if ( window.matchMedia('(prefers-color-scheme: dark)').matches ) {
106106
root.classList.add('dark');
107107
}
108+
109+
// https://github.com/uBlockOrigin/uBlock-issues/issues/1044
110+
// Offer the possibility to bypass uBO's default styling
111+
vAPI.messaging.send('uDom', { what: 'uiStyles' }).then(response => {
112+
if ( typeof response !== 'string' || response === 'unset' ) { return; }
113+
document.body.style.cssText = response;
114+
});
108115
}
109116

110117
/******************************************************************************/

0 commit comments

Comments
 (0)