From bcf5ac1feec0019663a3ad564caeb1c67679791e Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 6 Sep 2019 11:41:07 -0400 Subject: [PATCH] Add advanced setting to control logger popup type Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/663 The advanced setting `loggerPopupType` has been added, to control the type of window to be used when the logger is launched as a separate window. The default value is `popup`, it can be changed to any of the values documented at: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/windows/CreateType --- platform/chromium/vapi-background.js | 14 +++++++------- src/js/background.js | 1 + src/js/utils.js | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index 73ac3674967d6..2a96f71a3df2e 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -387,11 +387,11 @@ vAPI.Tabs = class { // Properties of the details object: // - url: 'URL', => the address that will be opened - // - index: -1, => undefined: end of the list, -1: following tab, or - // after index - // - active: false, => opens the tab in background - true and undefined: - // foreground - // - popup: true => open in a new window + // - index: -1, => undefined: end of the list, -1: following tab, + // or after index + // - active: false, => opens the tab... in background: true, + // foreground: undefined + // - popup: 'popup' => open in a new window create(url, details) { if ( details.active === undefined ) { @@ -443,10 +443,10 @@ vAPI.Tabs = class { // For some reasons, some platforms do not honor the left,top // position when specified. I found that further calling // windows.update again with the same position _may_ help. - if ( details.popup === true && browser.windows instanceof Object ) { + if ( details.popup !== undefined && browser.windows instanceof Object ) { const createDetails = { url: details.url, - type: 'popup', + type: details.popup, }; if ( details.box instanceof Object ) { Object.assign(createDetails, details.box); diff --git a/src/js/background.js b/src/js/background.js index 76c531047527e..172abec108572 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -52,6 +52,7 @@ const µBlock = (function() { // jshint ignore:line disableWebAssembly: false, ignoreRedirectFilters: false, ignoreScriptInjectFilters: false, + loggerPopupType: 'popup', manualUpdateAssetFetchPeriod: 500, popupFontSize: 'unset', requestJournalProcessPeriod: 1000, diff --git a/src/js/utils.js b/src/js/utils.js index ee04159d7adae..5c7a9a6fc8b66 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -386,8 +386,8 @@ !this.userSettings.alwaysDetachLogger ); } - details.popup = this.userSettings.alwaysDetachLogger; - if ( details.popup ) { + if ( this.userSettings.alwaysDetachLogger ) { + details.popup = this.hiddenSettings.loggerPopupType; const url = new URL(vAPI.getURL(details.url)); url.searchParams.set('popup', '1'); details.url = url.href;