MCPcopy Create free account
hub / github.com/Semporia/Scripts / GetCookie

Function GetCookie

JD_DailyBonus.js:1694–1725  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1692}
1693
1694function GetCookie() {
1695 const req = $request;
1696 if (req.method != 'OPTIONS' && req.headers) {
1697 const CV = (req.headers['Cookie'] || req.headers['cookie'] || '');
1698 const ckItems = CV.match(/(pt_key|pt_pin)=.+?;/g);
1699 if (/^https:\/\/(me-|)api(\.m|)\.jd\.com\/(client\.|user_new)/.test(req.url)) {
1700 if (ckItems && ckItems.length == 2) {
1701 const value = CookieUpdate(null, ckItems.join(''))
1702 if (value.type !== -1) {
1703 const write = $nobyda.write(JSON.stringify(value.total, null, 2), "CookiesJD")
1704 $nobyda.notify(`用户名: ${value.name}`, ``, `${value.type==2?`更新`:`写入`}京东 [账号${value.item}] Cookie${write?`成功 🎉`:`失败 ‼️`}`)
1705 } else {
1706 console.log(`\n用户名: ${value.name}\n与历史京东 [账号${value.item}] Cookie相同, 跳过写入 ⚠️`)
1707 }
1708 } else {
1709 throw new Error("写入Cookie失败, 关键值缺失\n可能原因: 非网页获取 ‼️");
1710 }
1711 } else if (/^https:\/\/ms\.jr\.jd\.com\/gw\/generic\/hy\/h5\/m\/appSign\?/.test(req.url) && req.body) {
1712 const value = CookieUpdate(CV, req.body, 'jrBody');
1713 if (value.type) {
1714 const write = $nobyda.write(JSON.stringify(value.total, null, 2), "CookiesJD")
1715 $nobyda.notify(`用户名: ${value.name}`, ``, `获取京东 [账号${value.item}] 钢镚Body${write?`成功 🎉`:`失败 ‼️`}`)
1716 } else {
1717 throw new Error("写入钢镚Body失败\n未获取该账号Cookie或关键值缺失‼️");
1718 }
1719 } else if (req.url === 'http://www.apple.com/') {
1720 throw new Error("类型错误, 手动运行请选择上下文环境为Cron ⚠️");
1721 }
1722 } else if (!req.headers) {
1723 throw new Error("写入Cookie失败, 请检查匹配URL或配置内脚本类型 ⚠️");
1724 }
1725}
1726
1727// Modified from yichahucha
1728function nobyda() {

Callers 1

JD_DailyBonus.jsFile · 0.70

Calls 4

CookieUpdateFunction · 0.85
writeMethod · 0.80
notifyMethod · 0.80
logMethod · 0.45

Tested by

no test coverage detected