From 60a23e00f8db9d227a7108caf8918531c535ca3b Mon Sep 17 00:00:00 2001 From: pipboy96 <46632672+pipboy96@users.noreply.github.com> Date: Sun, 31 Mar 2019 08:00:13 +0300 Subject: [PATCH] Fix bug in Chromium that makes popup links always load in non-incognito mode (#4247) --- chromium/pages/popup/ux.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/chromium/pages/popup/ux.js b/chromium/pages/popup/ux.js index 26a6a45a2c81..a15c1f895625 100644 --- a/chromium/pages/popup/ux.js +++ b/chromium/pages/popup/ux.js @@ -343,3 +343,15 @@ function getTab(callback) { } chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => callback(tabs[0])); } + +// This code fixes a Chromium-specific bug that causes links in extension popup +// to open in regular tab even if the popup is opened in incognito mode. + +document.addEventListener('click', e => { + const { target } = e + + if (target.matches('a[target="_blank"]')) { + chrome.tabs.create({ url: target.href }) + e.preventDefault() + } +})