From 162e53727099ccb0a088cc1399915fb23d9b4fec Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 22 May 2020 11:35:44 -0400 Subject: [PATCH] Make the creation of _allow_ rules in panel an opt-in feature There have been too many examples out there of users opting-in to "I am an advanced user" and yet still misusing dynamic filtering by creating _allow_ rules where _noop_ rules should be used. Creating _allow_ rules has serious consequences as these override blocking static filters and can potentially disable other advanced filtering ability such as HTML filtering and scriptlet injection -- often used to deal with anti-blocker mechanisms. The ability to point-and-click to create _allow_ rules from the popup panel is no longer allowed by default. An new advanced setting has been added to enable the ability to create _allow_ rules from the popup panel, `popupPanelGodMode`, which default to `false`. Set to `true` to restore ability to set _allow_ rules from popup panel. Since the creation of _allow_ rules is especially useful to filter list authors, to diagnose and narrow down site breakage as a result of problematic blocking filter, the creation of _allow_ rules will still be available when the advanced setting `filterAuthorMode` is `true`. This change is probably going to be problematic to all those users who were misusing dynamic filtering by creating _allow_ rules instead of _noop_ rules -- but the breakage is going to bring their misusing to their attention, a positive outcome. --- src/css/popup-fenix.css | 11 +++++++---- src/js/background.js | 1 + src/js/messaging.js | 14 ++++++++------ src/js/popup-fenix.js | 7 +++++++ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/css/popup-fenix.css b/src/css/popup-fenix.css index 71a2af874..9ebc0bda6 100644 --- a/src/css/popup-fenix.css +++ b/src/css/popup-fenix.css @@ -478,7 +478,9 @@ body.advancedUser #firewall > div > span.noopRule.ownRule, #actionSelector { box-sizing: border-box; + display: flex; height: 100%; + justify-items: stretch; left: 0; overflow: hidden; position: absolute; @@ -488,16 +490,17 @@ body.advancedUser #firewall > div > span.noopRule.ownRule, } #actionSelector > span { display: inline-block; - height: 100%; + flex-grow: 1; } #actionSelector > #dynaAllow { - width: 33%; + display: none; + } +body.godMode #actionSelector > #dynaAllow { + display: inline-block; } #actionSelector > #dynaNoop { - width: 33.5%; } #actionSelector > #dynaBlock { - width: 33.5%; } #actionSelector > #dynaCounts { background-color: transparent; diff --git a/src/js/background.js b/src/js/background.js index 8a357c97e..60175187a 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -68,6 +68,7 @@ const µBlock = (( ) => { // jshint ignore:line popupFontSize: 'unset', popupPanelDisabledSections: 0, popupPanelLockedSections: 0, + popupPanelGodMode: false, popupPanelHeightMode: 0, requestJournalProcessPeriod: 1000, selfieAfter: 3, diff --git a/src/js/messaging.js b/src/js/messaging.js index 85baa9190..c3a7c94cd 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -269,6 +269,7 @@ const popupDataFromTabId = function(tabId, tabTitle) { const tabContext = µb.tabContextManager.mustLookup(tabId); const rootHostname = tabContext.rootHostname; const µbus = µb.userSettings; + const µbhs = µb.hiddenSettings; const r = { advancedUserEnabled: µbus.advancedUserEnabled, appName: vAPI.app.name, @@ -278,7 +279,8 @@ const popupDataFromTabId = function(tabId, tabTitle) { firewallPaneMinimized: µbus.firewallPaneMinimized, globalAllowedRequestCount: µb.localSettings.allowedRequestCount, globalBlockedRequestCount: µb.localSettings.blockedRequestCount, - fontSize: µb.hiddenSettings.popupFontSize, + fontSize: µbhs.popupFontSize, + godMode: µbhs.filterAuthorMode || µbhs.popupPanelGodMode, netFilteringSwitch: false, rawURL: tabContext.rawURL, pageURL: tabContext.normalURL, @@ -288,16 +290,16 @@ const popupDataFromTabId = function(tabId, tabTitle) { pageBlockedRequestCount: 0, popupBlockedCount: 0, popupPanelSections: µbus.popupPanelSections, - popupPanelDisabledSections: µb.hiddenSettings.popupPanelDisabledSections, - popupPanelLockedSections: µb.hiddenSettings.popupPanelLockedSections, - popupPanelHeightMode: µb.hiddenSettings.popupPanelHeightMode, + popupPanelDisabledSections: µbhs.popupPanelDisabledSections, + popupPanelLockedSections: µbhs.popupPanelLockedSections, + popupPanelHeightMode: µbhs.popupPanelHeightMode, tabId: tabId, tabTitle: tabTitle, tooltipsDisabled: µbus.tooltipsDisabled }; - if ( µb.hiddenSettings.uiPopupConfig !== 'undocumented' ) { - r.uiPopupConfig = µb.hiddenSettings.uiPopupConfig; + if ( µbhs.uiPopupConfig !== 'undocumented' ) { + r.uiPopupConfig = µbhs.uiPopupConfig; } const pageStore = µb.pageStoreFromTabId(tabId); diff --git a/src/js/popup-fenix.js b/src/js/popup-fenix.js index 89c77301b..5d4afae0a 100644 --- a/src/js/popup-fenix.js +++ b/src/js/popup-fenix.js @@ -644,6 +644,13 @@ let renderOnce = function() { if ( popupData.popupPanelHeightMode === 1 ) { body.classList.add('vMin'); } + + // Prevent non-advanced user opting into advanced user mode from harming + // themselves by disabling by default features generally suitable to + // filter list maintainers and actual advanced users. + if ( popupData.godMode ) { + body.classList.add('godMode'); + } }; /******************************************************************************/