MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / parseExportCookie

Function parseExportCookie

packages/cloudscript/cloudscript.ts:38–65  ·  view source on GitHub ↗
(exportCookie: string)

Source from the content-addressed store, hash-verified

36
37// 解析导出cookie表达式生成导出的cookie
38export function parseExportCookie(exportCookie: string): Promise<ExportCookies[]> {
39 const lines = exportCookie.split("\n");
40 const result = [];
41 for (let i = 0; i < lines.length; i += 1) {
42 const line = lines[i];
43 const detail: ExportCookies = {};
44 if (line.trim()) {
45 for (const param of line.split(";")) {
46 const s = param.split("=");
47 if (s.length !== 2) {
48 continue;
49 }
50 detail[s[0].trim()] = s[1].trim();
51 }
52 if (detail.url || detail.domain) {
53 result.push(
54 new Promise<ExportCookies>((resolve) => {
55 getCookies(detail).then((cookies) => {
56 detail.cookies = cookies;
57 resolve(detail);
58 });
59 })
60 );
61 }
62 }
63 }
64 return Promise.all(result);
65}
66
67// 解析value表达式生成导出的value
68export async function parseExportValue(script: Script, exportValue: string): Promise<Value[]> {

Callers 1

CloudScriptPlanFunction · 0.90

Calls 2

getCookiesFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected