Skip to content

Commit

Permalink
🐛 修复火狐兼容问题
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Nov 7, 2022
1 parent 844d424 commit 88a6d4a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 23 deletions.
4 changes: 4 additions & 0 deletions build/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ if (version.prerelease) {
const firefoxManifest = { ...manifest };
const chromeManifest = { ...manifest };

delete chromeManifest.content_security_policy;

delete firefoxManifest.sandbox;
firefoxManifest.content_security_policy =
"script-src 'self' 'unsafe-eval'; object-src 'self'";
firefoxManifest.browser_specific_settings = {
gecko: { strict_min_version: "91.1.0" },
};
Expand Down
14 changes: 3 additions & 11 deletions src/app/message/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,10 @@ export default class MessageContent

nativeSend(data: any): void {
let detail = data;
if ((<{ cloneInto: any }>(<unknown>window)).cloneInto) {
if (typeof cloneInto !== "undefined") {
try {
detail = (<
{
cloneInto: (
// eslint-disable-next-line no-unused-vars, no-shadow
detail: any,
// eslint-disable-next-line no-unused-vars
view: any
) => { action: string; data: any };
}
>(<unknown>global)).cloneInto(detail, document.defaultView);
// eslint-disable-next-line no-undef
detail = cloneInto(detail, document.defaultView);
} catch (e) {
// eslint-disable-next-line no-console
console.log(e);
Expand Down
3 changes: 2 additions & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@
],
"sandbox": {
"pages": ["src/sandbox.html"]
}
},
"content_security_policy": "script-src 'self' blob:; object-src 'self' blob:"
}
1 change: 0 additions & 1 deletion src/pages/popup/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ switchLight(localStorage.lightMode || "auto");
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<div
style={{
height: "50px",
borderBottom: "1px solid var(--color-neutral-3)",
}}
>
Expand Down
9 changes: 1 addition & 8 deletions src/pkg/utils/cache_key.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// 缓存key,所有缓存相关的key都需要定义在此
// 使用装饰器维护缓存值

import Cache from "@App/app/cache";
import { ConfirmParam } from "@App/runtime/background/permission_verify";

export default class CacheKey {
Expand All @@ -23,12 +21,7 @@ export default class CacheKey {

// 加载脚本信息时的缓存,已处理删除
static scriptInfo(uuid: string): string {
const key = `scriptInfo:${uuid}`;
setTimeout(() => {
// 清理缓存
Cache.getInstance().del(key);
}, 60 * 1000);
return key;
return `scriptInfo:${uuid}`;
}

// 脚本资源url缓存,可能存在泄漏
Expand Down
4 changes: 2 additions & 2 deletions src/types/main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ declare let sandbox: Window;

declare let ScriptFlag: string;

declare let cloneInto: ((detail: any, view: any) => any) | undefined;

declare module "@App/types/scriptcat.d.ts";
declare module "*.tpl";

Expand Down Expand Up @@ -33,5 +35,3 @@ declare namespace GMSend {
filename?: string;
}
}


0 comments on commit 88a6d4a

Please sign in to comment.