Skip to content

Commit 88a6d4a

Browse files
committed
🐛 修复火狐兼容问题
1 parent 844d424 commit 88a6d4a

File tree

6 files changed

+12
-23
lines changed

6 files changed

+12
-23
lines changed

build/pack.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ if (version.prerelease) {
5656
const firefoxManifest = { ...manifest };
5757
const chromeManifest = { ...manifest };
5858

59+
delete chromeManifest.content_security_policy;
60+
5961
delete firefoxManifest.sandbox;
62+
firefoxManifest.content_security_policy =
63+
"script-src 'self' 'unsafe-eval'; object-src 'self'";
6064
firefoxManifest.browser_specific_settings = {
6165
gecko: { strict_min_version: "91.1.0" },
6266
};

src/app/message/content.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,10 @@ export default class MessageContent
7777

7878
nativeSend(data: any): void {
7979
let detail = data;
80-
if ((<{ cloneInto: any }>(<unknown>window)).cloneInto) {
80+
if (typeof cloneInto !== "undefined") {
8181
try {
82-
detail = (<
83-
{
84-
cloneInto: (
85-
// eslint-disable-next-line no-unused-vars, no-shadow
86-
detail: any,
87-
// eslint-disable-next-line no-unused-vars
88-
view: any
89-
) => { action: string; data: any };
90-
}
91-
>(<unknown>global)).cloneInto(detail, document.defaultView);
82+
// eslint-disable-next-line no-undef
83+
detail = cloneInto(detail, document.defaultView);
9284
} catch (e) {
9385
// eslint-disable-next-line no-console
9486
console.log(e);

src/manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@
4242
],
4343
"sandbox": {
4444
"pages": ["src/sandbox.html"]
45-
}
45+
},
46+
"content_security_policy": "script-src 'self' blob:; object-src 'self' blob:"
4647
}

src/pages/popup/main.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ switchLight(localStorage.lightMode || "auto");
3838
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
3939
<div
4040
style={{
41-
height: "50px",
4241
borderBottom: "1px solid var(--color-neutral-3)",
4342
}}
4443
>

src/pkg/utils/cache_key.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// 缓存key,所有缓存相关的key都需要定义在此
22
// 使用装饰器维护缓存值
3-
4-
import Cache from "@App/app/cache";
53
import { ConfirmParam } from "@App/runtime/background/permission_verify";
64

75
export default class CacheKey {
@@ -23,12 +21,7 @@ export default class CacheKey {
2321

2422
// 加载脚本信息时的缓存,已处理删除
2523
static scriptInfo(uuid: string): string {
26-
const key = `scriptInfo:${uuid}`;
27-
setTimeout(() => {
28-
// 清理缓存
29-
Cache.getInstance().del(key);
30-
}, 60 * 1000);
31-
return key;
24+
return `scriptInfo:${uuid}`;
3225
}
3326

3427
// 脚本资源url缓存,可能存在泄漏

src/types/main.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ declare let sandbox: Window;
22

33
declare let ScriptFlag: string;
44

5+
declare let cloneInto: ((detail: any, view: any) => any) | undefined;
6+
57
declare module "@App/types/scriptcat.d.ts";
68
declare module "*.tpl";
79

@@ -33,5 +35,3 @@ declare namespace GMSend {
3335
filename?: string;
3436
}
3537
}
36-
37-

0 commit comments

Comments
 (0)