fix save rule
This commit is contained in:
@@ -79,10 +79,13 @@ export default function Action({ translator, fab }) {
|
||||
}, [translator]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isGm) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 注册菜单
|
||||
const menuCommandIds = [];
|
||||
if (isGm) {
|
||||
try {
|
||||
const menuCommandIds = [];
|
||||
menuCommandIds.push(
|
||||
GM.registerMenuCommand(
|
||||
"Toggle Translate (Alt+q)",
|
||||
@@ -115,22 +118,15 @@ export default function Action({ translator, fab }) {
|
||||
"O"
|
||||
)
|
||||
);
|
||||
} catch (err) {
|
||||
console.log("[registerMenuCommand]", err);
|
||||
}
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (isGm) {
|
||||
try {
|
||||
menuCommandIds.forEach((id) => {
|
||||
GM.unregisterMenuCommand(id);
|
||||
});
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
}
|
||||
};
|
||||
} catch (err) {
|
||||
console.log("[registerMenuCommand]", err);
|
||||
}
|
||||
}, [translator]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -21,7 +21,12 @@ export default function Header({ setShowPopup }) {
|
||||
<IconButton onClick={handleHomepage}>
|
||||
<HomeIcon />
|
||||
</IconButton>
|
||||
<Box>
|
||||
<Box
|
||||
sx={{
|
||||
userSelect: "none",
|
||||
WebkitUserSelect: "none",
|
||||
}}
|
||||
>
|
||||
{`${process.env.REACT_APP_NAME} v${process.env.REACT_APP_VERSION}`}
|
||||
</Box>
|
||||
</Stack>
|
||||
|
||||
@@ -80,13 +80,12 @@ export default function Popup({ setShowPopup, translator: tran }) {
|
||||
|
||||
const handleSaveRule = async () => {
|
||||
try {
|
||||
let host = window.location.host;
|
||||
let href = window.location.href;
|
||||
if (isExt) {
|
||||
const tab = await getTabInfo();
|
||||
const url = new URL(tab.url);
|
||||
host = url.host;
|
||||
href = tab.url;
|
||||
}
|
||||
saveRule({ ...rule, pattern: host });
|
||||
saveRule({ ...rule, pattern: href });
|
||||
} catch (err) {
|
||||
console.log("[save rule]", err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user