1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 03:12:33 +01:00

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:
- https://github.com/uBlockOrigin/uBlock-issues/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.
This commit is contained in:
Raymond Hill 2020-05-19 10:33:36 -04:00
parent 5229e0c810
commit 9f7e5b621d
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
4 changed files with 12 additions and 1 deletions

View File

@ -8,7 +8,6 @@ body > div.body {
} }
h2, h3 { h2, h3 {
margin: 1em 0; margin: 1em 0;
font-family: sans-serif;
} }
h2 { h2 {
font-size: 18px; font-size: 18px;

View File

@ -74,6 +74,7 @@ const µBlock = (( ) => { // jshint ignore:line
suspendTabsUntilReady: 'unset', suspendTabsUntilReady: 'unset',
uiPopupConfig: 'undocumented', uiPopupConfig: 'undocumented',
uiFlavor: 'unset', uiFlavor: 'unset',
uiStyles: 'unset',
updateAssetBypassBrowserCache: false, updateAssetBypassBrowserCache: false,
userResourcesLocation: 'unset', userResourcesLocation: 'unset',
}; };

View File

@ -159,6 +159,10 @@ const onMessage = function(request, sender, callback) {
µb.toggleHostnameSwitch(request); µb.toggleHostnameSwitch(request);
break; break;
case 'uiStyles':
response = µb.hiddenSettings.uiStyles;
break;
case 'userSettings': case 'userSettings':
response = µb.changeUserSettings(request.name, request.value); response = µb.changeUserSettings(request.name, request.value);
break; break;

View File

@ -105,6 +105,13 @@ DOMListFactory.nodeFromSelector = function(selector) {
if ( window.matchMedia('(prefers-color-scheme: dark)').matches ) { if ( window.matchMedia('(prefers-color-scheme: dark)').matches ) {
root.classList.add('dark'); 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;
});
} }
/******************************************************************************/ /******************************************************************************/