Skip to content
Prev Previous commit
docs: document install provenance boundaries
  • Loading branch information
cyfung1031 committed Aug 18, 2026
commit efa07aab5ab06db26182d2ab7ef2465d1cf8a2f8
2 changes: 2 additions & 0 deletions src/app/service/service_worker/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ export class ScriptService {
action: {
type: "redirect" as chrome.declarativeNetRequest.RuleActionType,
redirect: {
// 直接 URL 入口不经过 UUID 暂存;byWebRequest 只在暂存链路中用于脚本身份匹配,
// 不能再作为安装页 history.back()/window.close() 的来源标记。
regexSubstitution: `${installPageURL}?url=\\1`,
},
},
Expand Down
2 changes: 2 additions & 0 deletions src/pages/install/useInstallData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ export function useInstallData(): UseInstallData {
});
const metadata = parseMetadata(code);
if (!metadata) throw new Error(t("install:script_info_load_failed"));
// 直接 URL 入口保持普通脚本准备参数;网页来源身份匹配只由 UUID 暂存选项传递,
// 安装页离开方式统一由 history.length 决定,不要为此重新添加 query 标记。
await loadFromInfo(buildScriptInfo(uuidv4(), code, parsed.href, metadata), false, {});
} else if (fid) {
const handle = await loadHandle(fid);
Expand Down
3 changes: 2 additions & 1 deletion src/pkg/utils/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ export async function prepareScriptByCode(
dao?: ScriptDAO,
options?: {
byEditor?: boolean; // 是否通过编辑器导入
byWebRequest?: boolean; // 是否通过网页连结安装或更新
// 仅控制网页来源脚本的身份匹配,不参与安装页 history.back()/window.close() 决策。
byWebRequest?: boolean;
}
): Promise<{ script: Script; oldScript?: Script; oldScriptCode?: string; oldInTrash?: boolean }> {
dao = dao ?? new ScriptDAO();
Expand Down
Loading