脚本打包
Some checks failed
build / Build (push) Failing after 6s
test / Run tests (push) Failing after 8s
Some checks failed
build / Build (push) Failing after 6s
test / Run tests (push) Failing after 8s
This commit is contained in:
@@ -21,8 +21,8 @@ export default class GMApi {
|
||||
readyState: <any>xhr.readyState,
|
||||
status: xhr.status,
|
||||
statusText: xhr.statusText,
|
||||
// header由service_worker处理
|
||||
// responseHeaders: xhr.getAllResponseHeaders().replace(removeXCat, ""),
|
||||
// header由service_worker处理,但是存在特殊域名(例如:edge.microsoft.com)无法获取的情况,在这里增加一个默认值
|
||||
responseHeaders: xhr.getAllResponseHeaders(),
|
||||
responseType: details.responseType,
|
||||
};
|
||||
if (xhr.readyState === 4) {
|
||||
|
@@ -168,7 +168,7 @@ export default class GMApi {
|
||||
"headersReceived:" + requestId,
|
||||
(details: chrome.webRequest.WebResponseHeadersDetails) => {
|
||||
details.responseHeaders?.forEach((header) => {
|
||||
responseHeader += header.name + ": " + header.value + "\n";
|
||||
responseHeader += header.name + ": " + header.value + "\r\n";
|
||||
});
|
||||
this.gmXhrHeadersReceived.removeAllListeners("headersReceived:" + requestId);
|
||||
}
|
||||
@@ -178,7 +178,9 @@ export default class GMApi {
|
||||
offscreenCon.onMessage((msg: { action: string; data: any }) => {
|
||||
// 发送到content
|
||||
// 替换msg.data.responseHeaders
|
||||
msg.data.responseHeaders = responseHeader;
|
||||
if (responseHeader) {
|
||||
msg.data.responseHeaders = responseHeader;
|
||||
}
|
||||
con.getConnect().sendMessage(msg);
|
||||
});
|
||||
}
|
||||
|
@@ -194,8 +194,6 @@ export class RuntimeService {
|
||||
})
|
||||
);
|
||||
|
||||
console.log("pageLoad", enableScript);
|
||||
|
||||
this.mq.emit("pageLoad", {
|
||||
tabId: chromeSender.tab?.id,
|
||||
frameId: chromeSender.frameId,
|
||||
|
@@ -57,7 +57,6 @@ export class ValueService {
|
||||
valueModel.data[key] = value;
|
||||
await this.valueDAO.save(storageName, valueModel);
|
||||
}
|
||||
console.log(valueModel);
|
||||
return true;
|
||||
});
|
||||
const sendData: ValueUpdateData = {
|
||||
|
@@ -5,7 +5,10 @@
|
||||
"scriptcat": {
|
||||
"message": "ScriptCat"
|
||||
},
|
||||
"scriptcat_beta": {
|
||||
"message": "ScriptCat Beta"
|
||||
},
|
||||
"scriptcat_description": {
|
||||
"message": "Everything can be scripted, allowing your browser to do more!"
|
||||
}
|
||||
}
|
||||
}
|
@@ -5,6 +5,9 @@
|
||||
"scriptcat": {
|
||||
"message": "ScriptCat"
|
||||
},
|
||||
"scriptcat_beta": {
|
||||
"message": "ScriptCat Beta"
|
||||
},
|
||||
"scriptcat_description": {
|
||||
"message": "Mọi thứ đều có thể viết được, cho phép trình duyệt của bạn làm được nhiều việc hơn!"
|
||||
}
|
||||
|
@@ -5,6 +5,9 @@
|
||||
"scriptcat": {
|
||||
"message": "脚本猫"
|
||||
},
|
||||
"scriptcat_beta": {
|
||||
"message": "脚本猫 Beta"
|
||||
},
|
||||
"scriptcat_description": {
|
||||
"message": "万物皆可脚本化,让你的浏览器可以做更多的事情!"
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@
|
||||
"default_locale": "zh_CN",
|
||||
"permissions": [
|
||||
"tabs",
|
||||
"action",
|
||||
"storage",
|
||||
"offscreen",
|
||||
"scripting",
|
||||
@@ -35,7 +34,7 @@
|
||||
"declarativeNetRequest"
|
||||
],
|
||||
"host_permissions": [
|
||||
"*://*/*"
|
||||
"<all_urls>"
|
||||
],
|
||||
"sandbox": {
|
||||
"pages": [
|
||||
|
@@ -8,6 +8,7 @@ import DBWriter from "@App/app/logger/db_writer.ts";
|
||||
import "@arco-design/web-react/dist/css/arco.css";
|
||||
import "@App/locales/locales";
|
||||
import "@App/index.css";
|
||||
import "./index.css";
|
||||
import { Provider } from "react-redux";
|
||||
import { store } from "../store/store.ts";
|
||||
|
||||
|
@@ -1,36 +1,14 @@
|
||||
import dts from "@App/types/scriptcat.d.ts";
|
||||
import { languages } from "monaco-editor";
|
||||
import pako from "pako";
|
||||
import Cache from "@App/app/cache";
|
||||
import { isDebug, isFirefox } from "./utils";
|
||||
import EventEmitter from "eventemitter3";
|
||||
|
||||
// 注册eslint
|
||||
const linterWorker = new Worker("/src/linter.worker.js");
|
||||
// const linterWorker = new Worker("/src/linter.worker.js");
|
||||
|
||||
export default function registerEditor() {
|
||||
// @ts-ignore
|
||||
window.tsUrl = "";
|
||||
|
||||
fetch(chrome.runtime.getURL(`/src/ts.worker.js${isFirefox() ? ".gz" : ""}`))
|
||||
.then((resp) => resp.blob())
|
||||
.then(async (blob) => {
|
||||
let result: ArrayBuffer;
|
||||
if (isDebug()) {
|
||||
result = await blob.arrayBuffer();
|
||||
} else {
|
||||
result = pako.inflate(await blob.arrayBuffer());
|
||||
}
|
||||
// @ts-ignore
|
||||
window.tsUrl = URL.createObjectURL(new Blob([result]));
|
||||
});
|
||||
// @ts-ignore
|
||||
window.MonacoEnvironment = {
|
||||
getWorkerUrl(moduleId: any, label: any) {
|
||||
if (label === "typescript" || label === "javascript") {
|
||||
// return "/src/ts.worker.js";
|
||||
// @ts-ignore
|
||||
return window.tsUrl;
|
||||
return "/src/ts.worker.js";
|
||||
}
|
||||
return "/src/editor.worker.js";
|
||||
},
|
||||
@@ -81,74 +59,74 @@ export default function registerEditor() {
|
||||
},
|
||||
});
|
||||
|
||||
// 处理quick fix
|
||||
languages.registerCodeActionProvider("javascript", {
|
||||
provideCodeActions: (model /** ITextModel */, range /** Range */, context /** CodeActionContext */) => {
|
||||
const actions: languages.CodeAction[] = [];
|
||||
const eslintFix = <Map<string, any>>Cache.getInstance().get("eslint-fix");
|
||||
for (let i = 0; i < context.markers.length; i += 1) {
|
||||
// 判断有没有修复方案
|
||||
const val = context.markers[i];
|
||||
const code = typeof val.code === "string" ? val.code : val.code!.value;
|
||||
const fix = eslintFix.get(
|
||||
`${code}|${val.startLineNumber}|${val.endLineNumber}|${val.startColumn}|${val.endColumn}`
|
||||
);
|
||||
if (fix) {
|
||||
const edit: languages.IWorkspaceTextEdit = {
|
||||
resource: model.uri,
|
||||
textEdit: {
|
||||
range: fix.range,
|
||||
text: fix.text,
|
||||
},
|
||||
versionId: undefined,
|
||||
};
|
||||
actions.push(<languages.CodeAction>{
|
||||
title: `修复 ${code} 问题`,
|
||||
diagnostics: [val],
|
||||
kind: "quickfix",
|
||||
edit: {
|
||||
edits: [edit],
|
||||
},
|
||||
isPreferred: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
// // 处理quick fix
|
||||
// languages.registerCodeActionProvider("javascript", {
|
||||
// provideCodeActions: (model /** ITextModel */, range /** Range */, context /** CodeActionContext */) => {
|
||||
// // const actions: languages.CodeAction[] = [];
|
||||
// // const eslintFix = <Map<string, any>>Cache.getInstance().get("eslint-fix");
|
||||
// // for (let i = 0; i < context.markers.length; i += 1) {
|
||||
// // // 判断有没有修复方案
|
||||
// // const val = context.markers[i];
|
||||
// // const code = typeof val.code === "string" ? val.code : val.code!.value;
|
||||
// // const fix = eslintFix.get(
|
||||
// // `${code}|${val.startLineNumber}|${val.endLineNumber}|${val.startColumn}|${val.endColumn}`
|
||||
// // );
|
||||
// // if (fix) {
|
||||
// // const edit: languages.IWorkspaceTextEdit = {
|
||||
// // resource: model.uri,
|
||||
// // textEdit: {
|
||||
// // range: fix.range,
|
||||
// // text: fix.text,
|
||||
// // },
|
||||
// // versionId: undefined,
|
||||
// // };
|
||||
// // actions.push(<languages.CodeAction>{
|
||||
// // title: `修复 ${code} 问题`,
|
||||
// // diagnostics: [val],
|
||||
// // kind: "quickfix",
|
||||
// // edit: {
|
||||
// // edits: [edit],
|
||||
// // },
|
||||
// // isPreferred: true,
|
||||
// // });
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// const actions = context.markers.map((error) => {
|
||||
// const edit: languages.IWorkspaceTextEdit = {
|
||||
// resource: model.uri,
|
||||
// textEdit: {
|
||||
// range,
|
||||
// text: "console.log(1)",
|
||||
// },
|
||||
// versionId: undefined,
|
||||
// };
|
||||
// return <languages.CodeAction>{
|
||||
// title: ``,
|
||||
// diagnostics: [error],
|
||||
// kind: "quickfix",
|
||||
// edit: {
|
||||
// edits: [edit],
|
||||
// },
|
||||
// isPreferred: true,
|
||||
// };
|
||||
// });
|
||||
return {
|
||||
actions,
|
||||
dispose: () => {},
|
||||
};
|
||||
},
|
||||
});
|
||||
// // const actions = context.markers.map((error) => {
|
||||
// // const edit: languages.IWorkspaceTextEdit = {
|
||||
// // resource: model.uri,
|
||||
// // textEdit: {
|
||||
// // range,
|
||||
// // text: "console.log(1)",
|
||||
// // },
|
||||
// // versionId: undefined,
|
||||
// // };
|
||||
// // return <languages.CodeAction>{
|
||||
// // title: ``,
|
||||
// // diagnostics: [error],
|
||||
// // kind: "quickfix",
|
||||
// // edit: {
|
||||
// // edits: [edit],
|
||||
// // },
|
||||
// // isPreferred: true,
|
||||
// // };
|
||||
// // });
|
||||
// return {
|
||||
// actions,
|
||||
// dispose: () => {},
|
||||
// };
|
||||
// },
|
||||
// });
|
||||
}
|
||||
|
||||
export class LinterWorker {
|
||||
static hook = new EventEmitter();
|
||||
// export class LinterWorker {
|
||||
// static hook = new EventEmitter();
|
||||
|
||||
static sendLinterMessage(data: unknown) {
|
||||
linterWorker.postMessage(data);
|
||||
}
|
||||
}
|
||||
// static sendLinterMessage(data: unknown) {
|
||||
// linterWorker.postMessage(data);
|
||||
// }
|
||||
// }
|
||||
|
||||
linterWorker.onmessage = (event) => {
|
||||
LinterWorker.hook.emit("message", event.data);
|
||||
};
|
||||
// linterWorker.onmessage = (event) => {
|
||||
// LinterWorker.hook.emit("message", event.data);
|
||||
// };
|
||||
|
Reference in New Issue
Block a user