From 85e6056a054136a5e088f0b6a5b923f9b8817435 Mon Sep 17 00:00:00 2001 From: Lars Johnsen Date: Mon, 16 Sep 2024 22:07:07 +0200 Subject: [PATCH] environment/permissions: Fix permission popup not showing `window.screen` is not available in manifest v3, causing the prompt window fallback method to fail. --- lib/environment/background/permissions.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/environment/background/permissions.js b/lib/environment/background/permissions.js index d8a6948d75..0810d2cee9 100644 --- a/lib/environment/background/permissions.js +++ b/lib/environment/background/permissions.js @@ -24,9 +24,11 @@ async function makePromptWindow({ permissions, origins }) { const width = 630; const height = 255; - // Display popup on middle of screen - const left = Math.floor(screen.width / 2 - width / 2); - const top = Math.floor(screen.height / 2 - height / 2); + + // Get the current window's dimensions and calculate center position + const { width: screenWidth, height: screenHeight } = await chrome.windows.getCurrent(); + const left = Math.floor(screenWidth / 2 - width / 2); + const top = Math.floor(screenHeight / 2 - height / 2); const { tabs: [{ id }] } = await apiToPromise(chrome.windows.create)({ url: url.href, type: 'popup', width, height, left, top });