add inactive icon if the domain is not whitelisted

This commit is contained in:
Jorrin
2024-03-03 22:56:13 +01:00
parent d74f0abbf6
commit 213828e818
5 changed files with 18 additions and 2 deletions

BIN
assets/active.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
assets/icon.development.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
assets/inactive.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@@ -54,6 +54,17 @@
"gecko": {
"id": "{3fd86354-c73f-4395-9e26-2c5c984579bf}"
}
}
},
"web_accessible_resources": [
{
"resources": [
"assets/active.png",
"assets/inactive.png"
],
"matches": [
"<all_urls>"
]
}
]
}
}

View File

@@ -1,4 +1,4 @@
import { useCallback } from 'react';
import { useCallback, useEffect } from 'react';
import { usePermission } from '~hooks/usePermission';
import { useDomainStorage } from '~utils/storage';
@@ -27,6 +27,11 @@ export function useToggleWhitelistDomain(domain: string) {
const { domainWhitelist, addDomain, removeDomain } = useDomainWhitelist();
const isWhitelisted = domainWhitelist.includes(domain);
const { grantPermission } = usePermission();
const iconPath = (chrome || browser).runtime.getURL(isWhitelisted ? 'assets/active.png' : 'assets/inactive.png');
(chrome || browser).action.setIcon({
path: iconPath,
});
const toggle = useCallback(() => {
if (!isWhitelisted) {