Skip to content

Commit

Permalink
Show correct status when manifest permission has been removed (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored Jun 26, 2024
1 parent 94100d8 commit 137a1fa
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,16 @@ async function updateItem(url?: string): Promise<void> {
if (isScriptableUrl(url)) {
const {origin} = new URL(url);

// Manifest permissions can't be removed; this disables the toggle on those domains
const isDefault = isUrlPermittedByManifest(url);

updateItemRaw({
enabled: !isDefault,
// We might have temporary permission as part of `activeTab`, so it needs to be properly checked
const hasPermission = await isOriginPermanentlyAllowed(origin);

// We might have temporary permission as part of `activeTab`, so it needs to be properly checked
checked: isDefault || await isOriginPermanentlyAllowed(origin),
updateItemRaw({
// Don't let the user remove a default permission.
// However, if they removed it via Chrome's UI, let them re-enable it with this toggle.
enabled: !isDefault || !hasPermission,
checked: hasPermission,
});
return;
}
Expand Down

0 comments on commit 137a1fa

Please sign in to comment.