MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / convertBrowserStringToNetscape

Method convertBrowserStringToNetscape

music/music.ts:756–785  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

754
755 for (const cookie of cookies) {
756 const [name, ...valueParts] = cookie.split("=");
757 const value = valueParts.join("="); // 处理值中包含 = 的情况
758
759 if (name && value) {
760 // YouTube cookies 默认设置
761 const domain = ".youtube.com";
762 const flag = "TRUE";
763 const path = "/";
764 const secure = "TRUE";
765 const expiry = Math.floor(Date.now() / 1000) + 31536000; // 1 year
766
767 netscapeLines.push(
768 `${domain}\t${flag}\t${path}\t${secure}\t${expiry}\t${name.trim()}\t${value.trim()}`
769 );
770 }
771 }
772
773 return netscapeLines.join("\n");
774 }
775
776 private static isEditThisCookieFormat(input: string): boolean {
777 // EditThisCookie 通常导出为带特定字段的 JSON
778 try {
779 const parsed = JSON.parse(input);
780 return (
781 Array.isArray(parsed) &&
782 parsed.length > 0 &&
783 (parsed[0].hasOwnProperty("storeId") ||
784 parsed[0].hasOwnProperty("sameSite"))
785 );
786 } catch {
787 return false;
788 }

Callers 1

convertToNetscapeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected