From 3a70d7d3b5b7d4690b0cb855d2b03a8d5e8de483 Mon Sep 17 00:00:00 2001 From: blackmatrix7 <27717518+blackmatrix7@users.noreply.github.com> Date: Tue, 28 Sep 2021 11:01:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EApple=20Store=20iPhone13?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E7=9B=91=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 + script/applestore/README.md | 107 +++++++++++++++ script/applestore/icon/applestore.png | Bin 0 -> 8636 bytes script/applestore/icon/applestore_dark.png | Bin 0 -> 5944 bytes script/applestore/iphone.js | 145 +++++++++++++++++++++ script/applestore/iphone.lnplugin | 6 + script/applestore/iphone.qxrewrite | 6 + script/applestore/iphone.sgmodule | 6 + script/boxjs.json | 42 +++++- 9 files changed, 313 insertions(+), 1 deletion(-) create mode 100644 script/applestore/README.md create mode 100644 script/applestore/icon/applestore.png create mode 100644 script/applestore/icon/applestore_dark.png create mode 100644 script/applestore/iphone.js create mode 100644 script/applestore/iphone.lnplugin create mode 100644 script/applestore/iphone.qxrewrite create mode 100644 script/applestore/iphone.sgmodule diff --git a/README.md b/README.md index b454af6b0..121019fef 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,8 @@ https://github.com/blackmatrix7/ios_rule_script/tree/master/rewrite | [Fa米家](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/famijia) | 每日自动签到 | 正常 | | [Luka](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/luka) | 每日自动签到 | 正常 | | [美团买菜](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/meituan) | 每日自动签到 | 正常 | +| [Synology](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/synology) | 群晖Downloads资源离线下载 | 正常 | +| [AppleStore](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/applestore) | AppleStore iPhone13 库存监控 | 暂停 | #### Quantumult X Gallery diff --git a/script/applestore/README.md b/script/applestore/README.md new file mode 100644 index 000000000..eebb30147 --- /dev/null +++ b/script/applestore/README.md @@ -0,0 +1,107 @@ + + +# Apple Store iPhone 库存监控 + +## 前言 + +这是一个可以让你感受绝望的脚本,感受那种明知有货,但还是抢不到的那种绝望。 + +长话短说,需要做一些准备: + +1. 在Apple官网上获取监控的商品 +2. 使用BoxJS配置监控的商品型号和地区 +3. 手机有足够的流量、电量 + +## 基础配置 + +### 确认型号 + +iPhone13 + +https://www.apple.com.cn/shop/buy-iphone/iphone-13/MLDH3CH/A + +iPhone 13 Pro + +https://www.apple.com.cn/shop/buy-iphone/iphone-13-pro/MLTE3CH/A + +在上面的链接中选择需要的型号、颜色、容量,然后把地址中类似MLDH3CH/A的文本复制下来,就是需要监控的型号 + +### 确认地区 + +省市示例:吉林 长春 朝阳区 + +直辖市示例:北京 北京 昌平区 + +## 进阶问题 + +### 脏数据 + +每次配置型号和地区,都必须在BoxJS中把`iphone_stock`的值清理掉,避免脏数据导致脚本异常。 + +### 监控间隔 + +移动端默认为5秒执行一次,NodeJS默认3秒执行一次。NodeJS可以使用Bark推送到手机,但因为需要再通过Bark服务端转发一次,会有些许延迟。 + +### 监控多个型号 + +脚本可以支持同时监控多个型号,但是**强烈不建议在移动端这么操作**。每次查询库存只能查询单个型号,配置多个型号需要进行多次查询,如果查询间隔设置得过小,可能导致上次脚本尚未执行完成,下轮监控又开始进行,造成重复推送。同时对手机的流量和电量都造成额外的消耗。 + +如果一定要监控多个型号,建议使用Node在服务器上运行,通过Bark推送监控结果。 + +## 通知说明 + +第一行 + +表示的是型号、颜色、容量和数据更新时间。 + +第二行 + +表示的本次监控的结果,监控店铺数量、售罄的店铺数量、有库存的店铺数量。最后会有一个实心或空心的圆圈。实心圆代表有库存的店铺,空心圆代表本次监控全部售罄。 + +余下通知内容 + +表示的是每家店铺的具体情况,小太阳表示有货,禁止符号表示售罄,紧接着是城市和店铺名称。 + +~~最后的箭头,↑ 代表上次查询售罄,本次查询有货。↓ 代表上次查询有货,本次查询售罄。○ 表示上次查询售罄,本次查询也售罄。●表示上次查询有货,本次查询也有货。~~这是去年监控iPhone12用的,监控iPhone13后简化了通知,箭头无意义。 + +点击通知可以跳转到Apple Store APP,如果你有安装的话。 + +## 配置说明 + +### Surge + +使用模块 + +```ini +https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/applestore/iphone.sgmodule +``` + +### Loon + +使用插件 + +```ini +https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/applestore/iphone.lnplugin +``` + +### Quantumult X + +配置文件 + +```ini +[task_local] +0/5 * 6-23 * * * https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/applestore/iphone.js, tag=AppleStore_iPhone库存监控, enabled=true +``` + +## 暂停维护 + +没错,刚刚更新就暂停维护了,如果没有严重的Bug不会再修改。 + +因为: + +1. 依照往年惯例,iPhone稳定供货后,苹果会关闭库存查询接口,脚本失效 +2. 每年库存查询接口都会有很大的变化,每年都需要重写 +3. ~~绝对不是因为我已经首发买到iPhone13 Pro Max~~ + +明年 iPhone14/13S 再见! + diff --git a/script/applestore/icon/applestore.png b/script/applestore/icon/applestore.png new file mode 100644 index 0000000000000000000000000000000000000000..c0054b184697871dc4d06b98845c34809fb74118 GIT binary patch literal 8636 zcmV;tAw%AYP)L%ec&Jf;^dGV&OyzLWTuhE)>dn# zHSNRhgMRM5?3=W*wK1*D3^gOo3@KhikRSm9-RQHbGBezLA0jfV8fcPT4S?kC(hZiV zE2|>E^zh?zk7&9(UZ9vm0V4z;TmXSS^(p3~fd&9{z=k*dsSm;hK74EJU;V};zUUty z0Lb!*0SZ_UG%Sx<1{4GcIB5lO zic$2Hr{6e&_*yiv*Fgt(0zp3s9|i=y|NN;wkKn0R^_!Cy4f>C-D;XGK z#iQg;dO~Gj9+NoWP5@-clh|G1PI>{(9gI&Z?AIcI`HfGP)@+V-

{~9_1Sc@oRA`00wo* z&Ns)8gb|78ssdaGG(Zc?fjQ6s9nd*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Os>^CF*@1+t9=#$ zt3_$fcYRBXE};CJ>$&UK#ZUjoB_fRGw6ed(Dou>iT1JdjiSA>F#vlQ+9tL1OFqge7 zQ`JyfYKoY?#-7J&*y-Ezw<(>;NF zW(&(=HrHsgOrUnoES}qT?^+&o-Yj~uiHFGIhx~oP1s6=Nz4qGjyjgVAK5WuugSh|} z8^EqBvEIZ35o~T@;P5=^(Y=8dnL{J1YeMt>JV&y5TM%t?`IQs=zUG>1%A-+=ka;TH zQGhwb+1O3Z10-HT7IsmYBD^u&hygzpbB}mnU)lD z%QaYLlUb;HG++$WrH&}287!0KOD^3;MhApJ```go>C*jL8hz}wH8k^yJFZ9o13S80-3GL-+&DBPi~@|o#4Xr%#H9_@6Dz?qf{8SC0|Oi&$1k27Yt*$oU!|we za2bdB@kA(3TGBUUbvr(9HWZ9La~K6!E}R7~^1hSAGkN?7z<3xO8j(sCof7S4n3Mco zEB`A-zJ4P9pJp!KL;#wUW*?B^F{1&C8$?~n706iFN)uUS#Rwfb`1LqG<}SCv@m~CP z0V6O+6m+lLUl_n5I8EIM4eOxiHTd-atnWRV3i#fH0&5mw z^BdyoO3?xG18wgPO)EU;w5T}9XmuqCs=k_~qiVJpCv%mPa` a-2VX?B9s;g^@=k90000 { + url = encodeURI(`https://www.apple.com.cn/shop/fulfillment-messages?pl=true&mt=compact&parts.0=${parts}&location=${location}`); + magicJS.get(url, (err, resp, data) => { + let obj = JSON.parse(data); + let stores = obj["body"]["content"]["pickupMessage"]["stores"]; + if (stores) { + resolve(stores); + } else { + magicJS.notify("查询库存失败,请检查配置是否正确。"); + resolve([]); + } + }); + }); +} + +async function watchStock(iphone_models, apple_store_region) { + let stock = magicJS.read(IPHONE_STOCK_KEY); + stock = !!stock ? stock : {}; + let len = iphone_models.length; + + for (let i = 0; i < len; i++) { + let parts = iphone_models[i]; + let subObj = { watch: 0, pickup: 0, soldout: 0, changed: 0 }; + let availability = await getiPhoneProStock(parts, apple_store_region); + + if (availability && availability.length > 0) { + // 获取AppleStore取货信息 + for (let store of availability) { + let storeNumber = store["storeNumber"]; + if (!stock.hasOwnProperty(parts)) { + stock[parts] = { title: store["partsAvailability"][parts]["storePickupProductTitle"], stores: {} }; + } + if (!stock[parts]["stores"][storeNumber]) { + stock[parts]["stores"][storeNumber] = { notify: false, pickup: false, msg: "等待查询", city: store["city"], name: store["storeName"] }; + } + if (stock[parts]["stores"][storeNumber]["msg"] != store["partsAvailability"][parts]["pickupSearchQuote"]) { + // 更新库存情况 + stock[parts]["stores"][storeNumber]["msg"] = store["partsAvailability"][parts]["pickupSearchQuote"]; + stock[parts]["stores"][storeNumber]["pickup"] = store["partsAvailability"][parts]["pickupDisplay"] != "unavailable"; + // 库存变化推送通知 + stock[parts]["stores"][storeNumber]["notify"] = true; + } else { + // 库存未变化不推送 + stock[parts]["stores"][storeNumber]["notify"] = false; + } + } + + let now = new Date(); + let logStr = `${stock[parts]["title"]}\n`; + let title = `${stock[parts]["title"]} - ${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`; + let watchResult = "全部售罄"; + let stockInContent = ""; // 有库存的型号与店铺 + let soldOutContent = ""; // 售罄的型号与店铺 + let unchangContent = ""; // 没有变化的型号与店铺 + let content = ""; + + // 整理通知内容 + for (let storeStock of Object.values(stock[parts]["stores"])) { + subObj["watch"] += 1; + // 有货 + if (storeStock["pickup"]) { + subObj["pickup"] += 1; + if (watchResult == "全部售罄") watchResult = `${storeStock["city"]} ${storeStock["name"]}`; + if (storeStock["notify"] === true) { + subObj["changed"] += 1; + if (!!stockInContent) stockInContent += "\n"; + stockInContent += `🔆 ${storeStock["name"]} - ${storeStock["msg"]}↑`; + } else { + if (!!unchangContent) unchangContent += "\n"; + unchangContent += `🔆 ${storeStock["name"]} - ${storeStock["msg"]}● `; + } + logStr += `${storeStock["name"]} - ${storeStock["msg"]}\n`; + } + + // 售罄 + else { + subObj["soldout"] += 1; + if (storeStock["notify"] === true) { + subObj["changed"] += 1; + if (!!soldOutContent) soldOutContent += "\n"; + soldOutContent += `🚫 ${storeStock["name"]} - ${storeStock["msg"]}↓`; + } else { + if (!!unchangContent) unchangContent += "\n"; + unchangContent += `🚫 ${storeStock["name"]} - ${storeStock["msg"]}○`; + } + logStr += `${storeStock["name"]} - ${storeStock["msg"]}\n`; + } + } + if (!!stockInContent) { + content = stockInContent; + } + // 配置为无货通知且存在无货情况时 + if (NOTIFY_SOLD_OUT) { + content = !!stockInContent ? stockInContent + `\n${soldOutContent}\n${unchangContent}` : `${soldOutContent}\n${unchangContent}`; + } + if (!!content) { + let subTitle = `监控: ${subObj.watch} 售罄: ${subObj.soldout} 有货: ${subObj.pickup} ${watchResult}`; + magicJS.notify(title, subTitle, content, "applestore://"); + } + magicJS.logInfo(logStr); + } + } + + // 存储本次库存检查结果 + magicJS.write(IPHONE_STOCK_KEY, stock); +} + +(async () => { + let iphone_model = magicJS.read(IPHONE_MODEL_KEY).trim(); + let apple_store_region = magicJS.read(APPLE_STORE_REGION_KEY).trim(); + + if (!iphone_model || !apple_store_region) { + let msg = "请先在BoxJS中配置心仪的iPhne型号及购买地区"; + magicJS.logWarning(msg); + magicJS.notify(msg); + return; + } + + let iphone_models = iphone_model.split(";"); + + // 监控库存 + await watchStock(iphone_models, apple_store_region); + + if (magicJS.isNode) { + while (6 <= new Date().getHours() <= 23) { + await watchStock(iphone_models, apple_store_region); + await magicJS.sleep(3000); + } + } + + magicJS.done(); +})(); + +// prettier-ignore +function MagicJS(scriptName="MagicJS",logLevel="INFO"){return new class{constructor(){if(this.version="2.2.3.5",this.scriptName=scriptName,this.logLevels={DEBUG:5,INFO:4,NOTIFY:3,WARNING:2,ERROR:1,CRITICAL:0,NONE:-1},this.isLoon="undefined"!=typeof $loon,this.isQuanX="undefined"!=typeof $task,this.isJSBox="undefined"!=typeof $drive,this.isNode="undefined"!=typeof module&&!this.isJSBox,this.isSurge="undefined"!=typeof $httpClient&&!this.isLoon,this.node={request:void 0,fs:void 0,data:{}},this.iOSUserAgent="Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1",this.pcUserAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36 Edg/84.0.522.59",this.logLevel=logLevel,this._barkUrl="",this._barkKey="",this.isNode){this.node.fs=require("fs"),this.node.request=require("request");try{this.node.fs.accessSync("./magic.json",this.node.fs.constants.R_OK|this.node.fs.constants.W_OK)}catch(err){this.node.fs.writeFileSync("./magic.json","{}",{encoding:"utf8"})}this.node.data=require("./magic.json")}else this.isJSBox&&($file.exists("drive://MagicJS")||$file.mkdir("drive://MagicJS"),$file.exists("drive://MagicJS/magic.json")||$file.write({data:$data({string:"{}"}),path:"drive://MagicJS/magic.json"}))}set barkUrl(url){try{let _url=url.replace(/\/+$/g,"");this._barkUrl=`${/^https?:\/\/([^/]*)/.exec(_url)[0]}/push`,this._barkKey=/\/([^\/]+)\/?$/.exec(_url)[1]}catch(err){this.logDebug("读取Bark推送链接失败。")}}set logLevel(level){this._logLevel="string"==typeof level?level.toUpperCase():"DEBUG"}get logLevel(){return this._logLevel}get isRequest(){return"undefined"!=typeof $request&&"undefined"==typeof $response}get isResponse(){return"undefined"!=typeof $response}get request(){return"undefined"!=typeof $request?$request:void 0}get response(){return"undefined"!=typeof $response?($response.hasOwnProperty("status")&&($response.statusCode=$response.status),$response.hasOwnProperty("statusCode")&&($response.status=$response.statusCode),$response):void 0}get platform(){return this.isSurge?"Surge":this.isQuanX?"Quantumult X":this.isLoon?"Loon":this.isJSBox?"JSBox":this.isNode?"Node.js":"Unknown"}read(key,session=""){let val="";this.isSurge||this.isLoon?val=$persistentStore.read(key):this.isQuanX?val=$prefs.valueForKey(key):this.isNode?val=this.node.data:this.isJSBox&&(val=$file.read("drive://MagicJS/magic.json").string);try{this.isNode&&(val=val[key]),this.isJSBox&&(val=JSON.parse(val)[key]),session&&("string"==typeof val&&(val=JSON.parse(val)),val=val&&"object"==typeof val?val[session]:null)}catch(err){this.logError(err),val=session?{}:null,this.del(key)}void 0===val&&(val=null);try{val&&"string"==typeof val&&(val=JSON.parse(val))}catch(err){}return this.logDebug(`READ DATA [${key}]${session?`[${session}]`:""}(${typeof val})\n${JSON.stringify(val)}`),val}write(key,val,session=""){let data=session?{}:"";if(session&&(this.isSurge||this.isLoon)?data=$persistentStore.read(key):session&&this.isQuanX?data=$prefs.valueForKey(key):this.isNode?data=this.node.data:this.isJSBox&&(data=JSON.parse($file.read("drive://MagicJS/magic.json").string)),session){try{"string"==typeof data&&(data=JSON.parse(data)),data="object"==typeof data&&data?data:{}}catch(err){this.logError(err),this.del(key),data={}}this.isJSBox||this.isNode?(data[key]&&"object"==typeof data[key]||(data[key]={}),data[key].hasOwnProperty(session)||(data[key][session]=null),void 0===val?delete data[key][session]:data[key][session]=val):void 0===val?delete data[session]:data[session]=val}else this.isNode||this.isJSBox?void 0===val?delete data[key]:data[key]=val:data=void 0===val?null:val;"object"==typeof data&&(data=JSON.stringify(data)),this.isSurge||this.isLoon?$persistentStore.write(data,key):this.isQuanX?$prefs.setValueForKey(data,key):this.isNode?this.node.fs.writeFileSync("./magic.json",data):this.isJSBox&&$file.write({data:$data({string:data}),path:"drive://MagicJS/magic.json"}),this.logDebug(`WRITE DATA [${key}]${session?`[${session}]`:""}(${typeof val})\n${JSON.stringify(val)}`)}del(key,session=""){this.logDebug(`DELETE KEY [${key}]${session?`[${session}]`:""}`),this.write(key,null,session)}notify(title=this.scriptName,subTitle="",body="",opts=""){let convertOptions;if(opts=(_opts=>{let newOpts={};if("string"==typeof _opts)this.isLoon?newOpts={openUrl:_opts}:this.isQuanX?newOpts={"open-url":_opts}:this.isSurge&&(newOpts={url:_opts});else if("object"==typeof _opts)if(this.isLoon)newOpts.openUrl=_opts["open-url"]?_opts["open-url"]:"",newOpts.mediaUrl=_opts["media-url"]?_opts["media-url"]:"";else if(this.isQuanX)newOpts=_opts["open-url"]||_opts["media-url"]?_opts:{};else if(this.isSurge){let openUrl=_opts["open-url"]||_opts.openUrl;newOpts=openUrl?{url:openUrl}:{}}return newOpts})(opts),1==arguments.length&&(title=this.scriptName,subTitle="",body=arguments[0]),this.logNotify(`title:${title}\nsubTitle:${subTitle}\nbody:${body}\noptions:${"object"==typeof opts?JSON.stringify(opts):opts}`),this.isSurge)$notification.post(title,subTitle,body,opts);else if(this.isLoon)opts?$notification.post(title,subTitle,body,opts):$notification.post(title,subTitle,body);else if(this.isQuanX)$notify(title,subTitle,body,opts);else if(this.isJSBox){let push={title:title,body:subTitle?`${subTitle}\n${body}`:body};$push.schedule(push)}this._barkUrl&&this._barkKey&&this.notifyBark(title,subTitle,body)}notifyDebug(title=this.scriptName,subTitle="",body="",opts=""){"DEBUG"===this.logLevel&&(1==arguments.length&&(title=this.scriptName,subTitle="",body=arguments[0]),this.notify(title,subTitle,body,opts))}notifyBark(title=this.scriptName,subTitle="",body="",opts=""){let options={url:this._barkUrl,headers:{"Content-Type":"application/json; charset=utf-8"},body:{title:title,body:subTitle?`${subTitle}\n${body}`:body,device_key:this._barkKey}};this.post(options,err=>{})}log(msg,level="INFO"){this.logLevels[this._logLevel]void 0===_options.body?"":`${encodeURIComponent(key)}=${encodeURIComponent(_options.body[key])}`).join("&");_options.url.indexOf("?")<0&&(_options.url+="?"),_options.url.lastIndexOf("&")+1!=_options.url.length&&_options.url.lastIndexOf("?")+1!=_options.url.length&&(_options.url+="&"),_options.url+=qs,delete _options.body}return this.isQuanX?(_options.hasOwnProperty("body")&&"string"!=typeof _options.body&&(_options.body=JSON.stringify(_options.body)),_options.method=method):this.isNode?(delete _options.headers["Accept-Encoding"],"object"==typeof _options.body&&("GET"===method?(_options.qs=_options.body,delete _options.body):"POST"===method&&(_options.json=!0,_options.body=_options.body))):this.isJSBox&&(_options.header=_options.headers,delete _options.headers),_options}adapterHttpResponse(resp){let _resp={body:resp.body,headers:resp.headers,json:()=>JSON.parse(_resp.body)};return resp.hasOwnProperty("statusCode")&&resp.statusCode&&(_resp.status=resp.statusCode),_resp}get(options,callback){let _options=this.adapterHttpOptions(options,"GET");this.logDebug(`HTTP GET: ${JSON.stringify(_options)}`),this.isSurge||this.isLoon?$httpClient.get(_options,callback):this.isQuanX?$task.fetch(_options).then(resp=>{resp.status=resp.statusCode,callback(null,resp,resp.body)},reason=>callback(reason.error,null,null)):this.isNode?this.node.request.get(_options,(err,resp,data)=>{resp=this.adapterHttpResponse(resp),callback(err,resp,data)}):this.isJSBox&&(_options.handler=resp=>{let err=resp.error?JSON.stringify(resp.error):void 0,data="object"==typeof resp.data?JSON.stringify(resp.data):resp.data;callback(err,resp.response,data)},$http.get(_options))}getPromise(options){return new Promise((resolve,reject)=>{magicJS.get(options,(err,resp)=>{err?reject(err):resolve(resp)})})}post(options,callback){let _options=this.adapterHttpOptions(options,"POST");if(this.logDebug(`HTTP POST: ${JSON.stringify(_options)}`),this.isSurge||this.isLoon)$httpClient.post(_options,callback);else if(this.isQuanX)$task.fetch(_options).then(resp=>{resp.status=resp.statusCode,callback(null,resp,resp.body)},reason=>{callback(reason.error,null,null)});else if(this.isNode){let resp=this.node.request.post(_options,callback);resp.status=resp.statusCode,delete resp.statusCode}else this.isJSBox&&(_options.handler=resp=>{let err=resp.error?JSON.stringify(resp.error):void 0,data="object"==typeof resp.data?JSON.stringify(resp.data):resp.data;callback(err,resp.response,data)},$http.post(_options,{}))}get http(){return{get:this.getPromise,post:this.post}}done(value={}){"undefined"!=typeof $done&&$done(value)}isToday(day){if(null==day)return!1;{let today=new Date;return"string"==typeof day&&(day=new Date(day)),today.getFullYear()==day.getFullYear()&&today.getMonth()==day.getMonth()&&today.getDay()==day.getDay()}}isNumber(val){return"NaN"!==parseFloat(val).toString()}attempt(promise,defaultValue=null){return promise.then(args=>[null,args]).catch(ex=>(this.logError(ex),[ex,defaultValue]))}retry(fn,retries=5,interval=0,callback=null){return(...args)=>new Promise((resolve,reject)=>{function _retry(...args){Promise.resolve().then(()=>fn.apply(this,args)).then(result=>{"function"==typeof callback?Promise.resolve().then(()=>callback(result)).then(()=>{resolve(result)}).catch(ex=>{retries>=1?interval>0?setTimeout(()=>_retry.apply(this,args),interval):_retry.apply(this,args):reject(ex),retries--}):resolve(result)}).catch(ex=>{this.logRetry(ex),retries>=1&&interval>0?setTimeout(()=>_retry.apply(this,args),interval):retries>=1?_retry.apply(this,args):reject(ex),retries--})}_retry.apply(this,args)})}formatTime(time,fmt="yyyy-MM-dd hh:mm:ss"){var o={"M+":time.getMonth()+1,"d+":time.getDate(),"h+":time.getHours(),"m+":time.getMinutes(),"s+":time.getSeconds(),"q+":Math.floor((time.getMonth()+3)/3),S:time.getMilliseconds()};/(y+)/.test(fmt)&&(fmt=fmt.replace(RegExp.$1,(time.getFullYear()+"").substr(4-RegExp.$1.length)));for(let k in o)new RegExp("("+k+")").test(fmt)&&(fmt=fmt.replace(RegExp.$1,1==RegExp.$1.length?o[k]:("00"+o[k]).substr((""+o[k]).length)));return fmt}now(){return this.formatTime(new Date,"yyyy-MM-dd hh:mm:ss")}today(){return this.formatTime(new Date,"yyyy-MM-dd")}sleep(time){return new Promise(resolve=>setTimeout(resolve,time))}}(scriptName)} diff --git a/script/applestore/iphone.lnplugin b/script/applestore/iphone.lnplugin new file mode 100644 index 000000000..e28114fa7 --- /dev/null +++ b/script/applestore/iphone.lnplugin @@ -0,0 +1,6 @@ +#!name=Apple Store +#!desc=定时获取Apple Store iPhone库存 +#!system=ios + +[Script] +Apple_获取iPhone库存 = type=cron,cronexp=0/5 * 6-23 * * *,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/applestore/iphone.js diff --git a/script/applestore/iphone.qxrewrite b/script/applestore/iphone.qxrewrite new file mode 100644 index 000000000..e28114fa7 --- /dev/null +++ b/script/applestore/iphone.qxrewrite @@ -0,0 +1,6 @@ +#!name=Apple Store +#!desc=定时获取Apple Store iPhone库存 +#!system=ios + +[Script] +Apple_获取iPhone库存 = type=cron,cronexp=0/5 * 6-23 * * *,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/applestore/iphone.js diff --git a/script/applestore/iphone.sgmodule b/script/applestore/iphone.sgmodule new file mode 100644 index 000000000..515a3c745 --- /dev/null +++ b/script/applestore/iphone.sgmodule @@ -0,0 +1,6 @@ +#!name=AppleStore +#!desc=定时获取AppleStore iPhone库存 +#!system=ios + +[Script] +Apple_获取iPhone库存 = type=cron,cronexp=0/5 * 6-23 * * *,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/applestore/iphone.js \ No newline at end of file diff --git a/script/boxjs.json b/script/boxjs.json index 0683934b8..1f02c9478 100644 --- a/script/boxjs.json +++ b/script/boxjs.json @@ -221,7 +221,7 @@ "script": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/zhihu/zhihu_plus.js" } ] - } + }, { "id": "blackmatrix7.synology", "name": "Synology", @@ -276,6 +276,46 @@ "script": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/synology/downloadstation.js" } ] + }, + { + "id": "blackmatrix7.applestore", + "name": "AppleStore", + "keys": ["iphone_model", "apple_store_region", "applestore_bark_url", "iphone_stock"], + "author": "@blackmatrix7", + "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/applestore", + "settings": [ + { + "id": "iphone_model", + "name": "iPhone型号", + "val": "", + "type": "input", + "placeholder": "MLDE3CH/A;MLDG3CH/A", + "autoGrow": true, + "desc": "需要监控的iPhone型号,多款以;分隔,移动端建议只监控一个" + }, + { + "id": "apple_store_region", + "name": "监控地区", + "val": "", + "type": "input", + "placeholder": "吉林 长春 朝阳区", + "autoGrow": true, + "desc": "直辖市示例:北京 北京 昌平区" + }, + { + "id": "applestore_bark_url", + "name": "Bark推送", + "val": "", + "type": "input", + "placeholder": "https://api.day.app/VXTWvaQ18N29bsQAg7DgkT", + "autoGrow": true, + "desc": "使用Bark推送到其他设备,比如iPad执行监控,推送结果到iPhone" + } + ], + "icons": [ + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/applestore/icon/applestore_dark.png", + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/applestore/icon/applestore.png" + ] } ] }