Skip to content

Commit

Permalink
environment/permissions: Fix permission popup not showing
Browse files Browse the repository at this point in the history
`window.screen` is not available in manifest v3, causing the prompt window fallback method to fail.
  • Loading branch information
larsjohnsen committed Sep 16, 2024
1 parent 2837707 commit 85e6056
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/environment/background/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand Down

0 comments on commit 85e6056

Please sign in to comment.