mirror of
https://github.com/movie-web/extension.git
synced 2025-09-13 11:03:26 +00:00
add inactive icon if the domain is not whitelisted
This commit is contained in:
BIN
assets/active.png
Normal file
BIN
assets/active.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
BIN
assets/icon.development.png
Normal file
BIN
assets/icon.development.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.6 KiB |
BIN
assets/inactive.png
Normal file
BIN
assets/inactive.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
13
package.json
13
package.json
@@ -54,6 +54,17 @@
|
|||||||
"gecko": {
|
"gecko": {
|
||||||
"id": "{3fd86354-c73f-4395-9e26-2c5c984579bf}"
|
"id": "{3fd86354-c73f-4395-9e26-2c5c984579bf}"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"web_accessible_resources": [
|
||||||
|
{
|
||||||
|
"resources": [
|
||||||
|
"assets/active.png",
|
||||||
|
"assets/inactive.png"
|
||||||
|
],
|
||||||
|
"matches": [
|
||||||
|
"<all_urls>"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { useCallback } from 'react';
|
import { useCallback, useEffect } from 'react';
|
||||||
|
|
||||||
import { usePermission } from '~hooks/usePermission';
|
import { usePermission } from '~hooks/usePermission';
|
||||||
import { useDomainStorage } from '~utils/storage';
|
import { useDomainStorage } from '~utils/storage';
|
||||||
@@ -27,6 +27,11 @@ export function useToggleWhitelistDomain(domain: string) {
|
|||||||
const { domainWhitelist, addDomain, removeDomain } = useDomainWhitelist();
|
const { domainWhitelist, addDomain, removeDomain } = useDomainWhitelist();
|
||||||
const isWhitelisted = domainWhitelist.includes(domain);
|
const isWhitelisted = domainWhitelist.includes(domain);
|
||||||
const { grantPermission } = usePermission();
|
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(() => {
|
const toggle = useCallback(() => {
|
||||||
if (!isWhitelisted) {
|
if (!isWhitelisted) {
|
||||||
|
Reference in New Issue
Block a user