Skip to content

Commit f094d80

Browse files
committed
🐛 修复某些以.user.js为后缀的网页识别成安装脚本
1 parent 0794cd3 commit f094d80

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/pages/install/description.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,11 @@ export default function Description() {
299299
subscribeCtrl
300300
.upsert(upsertScript as Subscribe)
301301
.then(() => {
302-
Message.success("订阅成功,1秒后关闭窗口");
302+
Message.success("订阅成功");
303303
setBtnText("订阅成功");
304304
setTimeout(() => {
305305
closeWindow();
306-
}, 1000);
306+
}, 200);
307307
})
308308
.catch((e) => {
309309
Message.error(`订阅失败: ${e}`);
@@ -314,15 +314,15 @@ export default function Description() {
314314
.upsert(upsertScript as Script)
315315
.then(() => {
316316
if (isUpdate) {
317-
Message.success("更新成功,1秒后关闭窗口");
317+
Message.success("更新成功");
318318
setBtnText("更新成功");
319319
} else {
320-
Message.success("安装成功,1秒后关闭窗口");
320+
Message.success("安装成功");
321321
setBtnText("安装成功");
322322
}
323323
setTimeout(() => {
324324
closeWindow();
325-
}, 1000);
325+
}, 200);
326326
})
327327
.catch((e) => {
328328
Message.error(`安装失败: ${e}`);

src/pages/options/routes/ScriptList.tsx

+16
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,22 @@ function installUrlToHome(installUrl: string) {
124124
/>
125125
);
126126
}
127+
if (installUrl.indexOf("github.com") !== -1) {
128+
const repo = `${installUrl.split("/")[3]}/${installUrl.split("/")[4]}`;
129+
return (
130+
<Button
131+
type="text"
132+
iconOnly
133+
size="small"
134+
target="_blank"
135+
href={`https://github.com/${repo}`}
136+
style={{
137+
color: "var(--color-text-1)",
138+
}}
139+
icon={<IconGithub />}
140+
/>
141+
);
142+
}
127143
} catch (e) {
128144
// ignore error
129145
}

src/pkg/utils/script.ts

+4
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ export async function fetchScriptInfo(
106106
if (resp.status !== 200) {
107107
throw new Error("fetch script info failed");
108108
}
109+
if (resp.headers.get("content-type")?.indexOf("text/html") !== -1) {
110+
throw new Error("url is html");
111+
}
112+
109113
const body = await resp.text();
110114
const ok = parseMetadata(body);
111115
if (!ok) {

0 commit comments

Comments
 (0)