dsh-gacha-calendar 0.9.39 → 0.9.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/client.js +52 -16
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -4,7 +4,7 @@
4
4
  // 用途:缓存里记录"这份数据是哪版插件产出的"。更新插件后首次启动,据此**强制**刷新一次
5
5
  // (不看自动刷新开关)——因为有些改动(悬停格式、来源地址、样式、解析器)不刷新就看不到效果。
6
6
  // 写入时机见 engine-api.js 的 refresh();判定见 60-helpers.js 的 autoRefreshPlan()。
7
- const PLUGIN_VERSION = "0.9.39";
7
+ const PLUGIN_VERSION = "0.9.40";
8
8
  //#endregion
9
9
 
10
10
  window.__ModuleLoader__.load({
@@ -322,7 +322,7 @@ window.__ModuleLoader__.load({
322
322
  },
323
323
  {
324
324
  id: "r1999",
325
- parserVersion: 2,
325
+ parserVersion: 3,
326
326
  name: "重返未来:1999",
327
327
  icon: "https://play-lh.googleusercontent.com/LwcueZMBbLq6aELtqJVn61ToKkJUgxEO8O4KgK_5052hfYoDAglQJIzqSu8srUJeaOZwv36Qi5YKtsXZjo-JPg=s64",
328
328
  source: "\u5B98\u65B9\u516C\u544A",
@@ -2665,7 +2665,31 @@ window.__ModuleLoader__.load({
2665
2665
  return "";
2666
2666
  }
2667
2667
 
2668
- // 解析一篇「版本活动一览」→ { pools, events, rotations }
2668
+ // 独立池公告:标题形如「池名」类型开启!,正文只有一张图(拿不到 UP 名单),
2669
+ // 但接口的 beginTime/endTime 就是该池的真实起止。官方**逐池各发一篇**,且**过期即从公告板下线**:
2670
+ // 实测公告板上 22 条无一条过期,已结束的池与其轮换期全都没有公告("有公告" ⟺ "该池在开")。
2671
+ // 所以轮换征集只能靠它——一览里那三行日期不带时间,过期后连日期行也会随版本一起消失。
2672
+ const R99_SOLO_POOL = /^\u300c([^\u300d]{1,40})\u300d([^\u300c\u300d]{1,12})\u5f00\u542f\uff01$/;
2673
+ function r99SoloPools(items) {
2674
+ const out = [];
2675
+ for (const it of items) {
2676
+ const title = String((it.contentMap && it.contentMap["zh-CN"] && it.contentMap["zh-CN"].title) || "").trim();
2677
+ const m = title.match(R99_SOLO_POOL);
2678
+ if (!m) continue;
2679
+ const kind = m[2].trim();
2680
+ if (R99_POOL_TIERS.indexOf(kind) < 0) continue; // 衣着上新/上架/上新等不是卡池
2681
+ const startTs = Number(it.beginTime);
2682
+ const endTs = Number(it.endTime) - 6e4; // 接口边界是排他的(…05:00),面板统一显示末分钟 04:59
2683
+ if (!startTs || !endTs) continue;
2684
+ out.push({
2685
+ name: `\u300c${m[1]}\u300d${kind}`, kind, roles: "", startTs, endTs, raw: "",
2686
+ display: fmtWindow(startTs, endTs)
2687
+ });
2688
+ }
2689
+ return out;
2690
+ }
2691
+
2692
+ // 解析一篇「版本活动一览」→ { pools, events, rotRows }
2669
2693
  function parseR99Overview(item, now = nowMs()) {
2670
2694
  const lines = r99NoticeLines(item);
2671
2695
  if (!lines) return null;
@@ -2720,20 +2744,16 @@ window.__ModuleLoader__.load({
2720
2744
  seenEvent.add(key);
2721
2745
  events.push({ name: sec.name, cat: sec.kind, startTs, endTs, raw: fmtWindow(startTs, endTs) });
2722
2746
  }
2723
- // 轮换征集:一览以「X月X日更新:角色、角色」逐期公布(14 天一期,末日 04:59)
2724
- const rotations = [];
2747
+ // 轮换征集在一览里**只有日期行**(「N月N日更新:角色」,不带起止时间)→ 这里只当"角色字典"。
2748
+ // 时间不再用"+14 天"推算:每期轮换都有自己的独立公告(见 r99SoloPools),接口给的就是真实起止。
2749
+ const rotRows = [];
2725
2750
  for (const line of lines) {
2726
2751
  const m = line.match(/^(\d{1,2})\u6708(\d{1,2})\u65e5\u66f4\u65b0[\uff1a:]\s*(.+)$/);
2727
2752
  if (!m) continue;
2728
- const startTs = new Date(year, Number(m[1]) - 1, Number(m[2]), 5, 0).getTime();
2729
- const endTs = startTs + 14 * 864e5 - 6e4;
2730
- rotations.push({
2731
- name: "\u300c\u8f6e\u6362\u5f81\u96c6\u300d", kind: "\u8f6e\u6362\u5f81\u96c6", roles: cleanRoles(m[3]),
2732
- startTs, endTs, raw: `\u3010${m[1]}\u6708${m[2]}\u65e5\u66f4\u65b0\u3011${cleanRoles(m[3])}`,
2733
- display: fmtWindow(startTs, endTs)
2734
- });
2753
+ // 只用"更新日"当匹配键(与同一期独立公告的 startTs 同一天),不作为时间来源
2754
+ rotRows.push({ startTs: new Date(year, Number(m[1]) - 1, Number(m[2]), 5, 0).getTime(), roles: cleanRoles(m[3]) });
2735
2755
  }
2736
- return { pools, events, rotations };
2756
+ return { pools, events, rotRows };
2737
2757
  }
2738
2758
 
2739
2759
  // 官方游戏内公告 → 当期征集(含真实起止、悬停列全部并行)+ 当期活动(同其它游戏的活动列规则)。
@@ -2746,7 +2766,7 @@ window.__ModuleLoader__.load({
2746
2766
  const titleOf = (it) => String((it.contentMap && it.contentMap["zh-CN"] && it.contentMap["zh-CN"].title) || "");
2747
2767
  const overviews = items.filter((it) => /\u7248\u672c\u6d3b\u52a8\u4e00\u89c8/.test(titleOf(it)));
2748
2768
  if (overviews.length === 0) throw new Error("r1999-notice-no-section");
2749
- const pools = [], events = [], rotations = [];
2769
+ const pools = [], events = [], rotRows = [];
2750
2770
  let parsed = 0;
2751
2771
  for (const it of overviews) {
2752
2772
  const o = parseR99Overview(it, now);
@@ -2754,11 +2774,27 @@ window.__ModuleLoader__.load({
2754
2774
  parsed++;
2755
2775
  pools.push.apply(pools, o.pools);
2756
2776
  events.push.apply(events, o.events);
2757
- rotations.push.apply(rotations, o.rotations);
2777
+ rotRows.push.apply(rotRows, o.rotRows);
2758
2778
  }
2759
2779
  if (parsed === 0) throw new Error("r1999-notice-no-dates");
2780
+ // 用独立公告补齐一览没有的池(当前就是轮换征集)。同名池**以一览为准**——它有正文【征集时间】
2781
+ // 与 UP 名单;独立公告正文只有图,只能补"池名 + 真实起止",角色另从日期行字典里按同一天取。
2782
+ const dayKey = (ts) => { const d = new Date(ts); return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`; };
2783
+ const rolesByDay = new Map(rotRows.map((r) => [dayKey(r.startTs), r.roles]));
2784
+ for (const p of r99SoloPools(items)) {
2785
+ if (pools.some((x) => x.name === p.name)) continue;
2786
+ p.roles = rolesByDay.get(dayKey(p.startTs)) || "";
2787
+ pools.push(p);
2788
+ }
2760
2789
  const data = {};
2761
- const active = pools.concat(rotations).filter((p) => p.startTs <= now && p.endTs >= now);
2790
+ // 当期 = 窗口覆盖现在的池;同名多期(一览的下一期 + 公告的当期)只留第一个 = 一览优先
2791
+ const seenName = new Set();
2792
+ const active = pools.filter((p) => {
2793
+ if (!(p.startTs <= now && p.endTs >= now)) return false;
2794
+ if (seenName.has(p.name)) return false;
2795
+ seenName.add(p.name);
2796
+ return true;
2797
+ });
2762
2798
  if (active.length > 0) {
2763
2799
  const rank = (p) => {
2764
2800
  const i = R99_POOL_TIERS.indexOf(p.kind);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gacha-calendar",
3
- "version": "0.9.39",
3
+ "version": "0.9.40",
4
4
  "description": "二游活动/卡池排期速查:侧边栏底部按钮,点击展开 11 款已安装二游的当前版本、卡池与活动起止;支持联网自动刷新与刷新频率设置(原神/星铁/绝区零/鸣潮/明日方舟/终末地/蔚蓝档案国服+国际服+日服/重返未来1999/异环)。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",