全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 3612|回复: 27

[疑问] Kurun 洛杉矶SAS2 1.5刀库存监控

[复制链接]
发表于 2021-5-4 09:28:59 | 显示全部楼层 |阅读模式
本帖最后由 zxxx 于 2021-5-4 09:28 编辑

安装 Chrome 扩展

Web Data Monitor: https://chrome.google.com/webstore/detail/web-data-monitor/jicncdodkpdlndbppohjljcggoemckjp

添加任务



  1. Kurun 洛杉矶SAS2 1.5刀库存监控
复制代码

  1. https://www.kurun.com/clients.html#/order-config?pid=35
复制代码

  1. {
  2.   "type": "get",
  3.   "url": "https://www.kurun.com/cart/index?first_gid=5",
  4.   "dataType": "json",
  5.   "timeout": 7000,
  6. }
复制代码

  1. var url = presetPageUrl;
  2. var highlight = lastReturn.highlight;
  3. var popup = lastReturn.popup;
  4. var content = lastReturn.content;
  5. var extra = lastReturn.extra | 0;
  6. popup = false;
  7. highlight = true;
  8. content = '【洛杉矶SAS2】当前库存:';
  9. if (queryResult.status != 200) {
  10.     popup = true;
  11.     content += '查询失败!';
  12. } else {
  13.     qty = queryResult.products[3].qty;
  14.     content += qty;
  15.     if (extra != qty) {
  16.         popup = true;
  17.     }
  18.     extra = qty;
  19. }
  20. return {
  21.     'highlight': highlight,
  22.     'popup': popup,
  23.     'url': url,
  24.     'content': content,
  25.     'extra': extra
  26. };
复制代码


发表于 2021-5-4 20:24:40 | 显示全部楼层
本帖最后由 northlan 于 2021-5-4 20:27 编辑

同时监控所有 first_gid=5 的产品,显示上由于不能换行,就管它呢,反正有弹窗提醒。
另外这个url不知道跟购买页面有没啥区别,我看上面产品的价格不对应。

弹窗逻辑是 总量不等于上次请求的总量。


  1. var url = presetPageUrl;
  2. var highlight = lastReturn.highlight;
  3. var popup = lastReturn.popup;
  4. var content = lastReturn.content;
  5. var extra = lastReturn.extra | 0;
  6. popup = false;
  7. highlight = true;
  8. content = '';
  9. if (queryResult.status != 200) {
  10.     popup = true;
  11.     content += '查询失败!';
  12. } else {
  13.     const products = []
  14.     let sum = 0
  15.     queryResult.products.forEach(it => {
  16.         const {
  17.           name,
  18.           qty
  19.         } = it
  20.         products.push(`${name}:【${qty}】`)
  21.         sum += qty
  22.     });
  23.     content = products.join('| ')
  24.    
  25.     if (extra != sum) {
  26.         popup = true;
  27.     }
  28.     extra = sum;
  29. }

  30. return {
  31.     'highlight': highlight,
  32.     'popup': popup,
  33.     'url': url,
  34.     'content': content,
  35.     'extra': extra
  36. };
复制代码



展示效果这样

洛杉矶LAX1: 【0】| 洛杉矶LAX2:【0】

如果要取消这个中文,改这个就行

  1. products.push(`${name.replace('洛杉矶','')}:【${qty}】`)
复制代码
 楼主| 发表于 2021-5-4 09:29:00 | 显示全部楼层
或者直接导入配置

  1. [
  2.   {
  3.     "id": "Kurun1620081213128",
  4.     "name": "Kurun 洛杉矶SAS2 1.5刀库存监控",
  5.     "presetPageUrl": "https://www.kurun.com/clients.html#/order-config?pid=35",
  6.     "faviconUrl": "https://www.kurun.com/favicon.ico",
  7.     "isRefresh": false,
  8.     "period": "5000",
  9.     "allowPopup": true,
  10.     "ajaxOption": "{\n  "type": "get",\n  "url": "https://www.kurun.com/cart/index?first_gid=5",\n  "dataType": "json",\n  "timeout": 7000,\n}",
  11.     "processor": "var url = presetPageUrl; \nvar highlight = lastReturn.highlight; \nvar popup = lastReturn.popup; \nvar content = lastReturn.content; \nvar extra = lastReturn.extra | 0; \npopup = false;\nhighlight = true;\ncontent = '【洛杉矶SAS2】当前库存:';\nif (queryResult.status != 200) {\n    popup = true;\n    content += '查询失败!';\n} else {\n    qty = queryResult.products[3].qty;\n    content += qty;\n    if (extra != qty) {\n        popup = true;\n    }\n    extra = qty;\n}\nreturn {\n    'highlight': highlight,\n    'popup': popup,\n    'url': url,\n    'content': content,\n    'extra': extra\n};",
  12.     "result": {
  13.       "highlight": true,
  14.       "popup": false,
  15.       "url": "https://www.kurun.com/clients.html#/order-config?pid=35",
  16.       "content": "【洛杉矶SAS2】当前库存:0",
  17.       "extra": 0,
  18.       "time": 1620090461642
  19.     }
  20.   }
  21. ]
复制代码


以上代码另存为 kurun.json 然后导入即可。

发表于 2021-5-4 09:33:43 | 显示全部楼层
感谢大佬分享
 楼主| 发表于 2021-5-4 09:33:50 | 显示全部楼层

谁知道呢?万一有了呢
发表于 2021-5-4 09:39:30 | 显示全部楼层
lz大佬有博客吗。想跟你学东西
 楼主| 发表于 2021-5-4 09:40:18 | 显示全部楼层
七黑 发表于 2021-5-4 09:39
lz大佬有博客吗。想跟你学东西

技术不行,不会建站啊
 楼主| 发表于 2021-5-4 09:45:22 | 显示全部楼层
可以添加其他配置,监控其他库存

  1.     qty = queryResult.products[3].qty;
复制代码


products[0]:洛杉矶LAX1

products[1]:洛杉矶LAX2

products[2]:洛杉矶SAS1

products[3]:洛杉矶SAS2

点评

大佬棒棒哒  发表于 2021-5-4 14:16
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-26 04:36 , Processed in 0.078204 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表