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