From 9f7e5b621dc5e7a3e0fed0daa57d922f1ec56d80 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 19 May 2020 10:33:36 -0400 Subject: [PATCH] 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. --- src/css/dashboard-common.css | 1 - src/js/background.js | 1 + src/js/messaging.js | 4 ++++ src/js/udom.js | 7 +++++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/css/dashboard-common.css b/src/css/dashboard-common.css index 0c1ef842d..562923443 100644 --- a/src/css/dashboard-common.css +++ b/src/css/dashboard-common.css @@ -8,7 +8,6 @@ body > div.body { } h2, h3 { margin: 1em 0; - font-family: sans-serif; } h2 { font-size: 18px; diff --git a/src/js/background.js b/src/js/background.js index 5d82da6ad..7ed4db62d 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -74,6 +74,7 @@ const µBlock = (( ) => { // jshint ignore:line suspendTabsUntilReady: 'unset', uiPopupConfig: 'undocumented', uiFlavor: 'unset', + uiStyles: 'unset', updateAssetBypassBrowserCache: false, userResourcesLocation: 'unset', }; diff --git a/src/js/messaging.js b/src/js/messaging.js index 457c38b2d..7a67a7423 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -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; diff --git a/src/js/udom.js b/src/js/udom.js index 268aec049..cd032fb0c 100644 --- a/src/js/udom.js +++ b/src/js/udom.js @@ -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; + }); } /******************************************************************************/