(account)
| 188 | } |
| 189 | |
| 190 | function ListProduct(account) { |
| 191 | const opts = { |
| 192 | url: 'https://manga.bilibili.com/twirp/pointshop.v1.Pointshop/ListProduct', |
| 193 | headers: { |
| 194 | "User-Agent": "comic-universal/3412 CFNetwork/1410.0.3 Darwin/22.6.0 os/ios model/iPhone 12 mobi_app/iphone_comic build/3412 osVer/16.6 network/2 channel/AppStore" |
| 195 | }, |
| 196 | throwHttpErrors: false |
| 197 | }; |
| 198 | |
| 199 | $.debug(`Send ListProduct request:`, $.toStr(opts, null, null, 1)); |
| 200 | |
| 201 | return $.http.post(opts) |
| 202 | .then((resp) => { |
| 203 | $.debug(`Receive ListProduct response:`, $.toStr(resp, null, null, 1)); |
| 204 | const body = JSON.parse(resp.body?.startsWith('{') && resp.body || '{}'); |
| 205 | if (body.code == 0 && body.data && body.data.length >= 1) { |
| 206 | return body.data; |
| 207 | } else { |
| 208 | throw new Error(body.msg || '查询商品列表失败'); |
| 209 | } |
| 210 | }) |
| 211 | .catch((err) => { |
| 212 | $.error(`ListProduct error:`, err); |
| 213 | throw err; |
| 214 | }); |
| 215 | } |
| 216 | |
| 217 | function StartExchange(account, product, num, attempt) { |
| 218 | const opts = { |
no test coverage detected