@iasiv5/dsh-quota-watch 0.0.12 → 0.0.14

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.
package/lib/client.js CHANGED
@@ -106,7 +106,7 @@ var COPY = {
106
106
  todayCalls: "\u8C03\u7528\u6B21\u6570",
107
107
  weekUnlimited: "\u6BCF\u5468\u989D\u5EA6",
108
108
  unlimited: "\u267E\uFE0F",
109
- unlimitedNote: "\uFF08\u65E0\u9650\uFF09",
109
+ unlimitedNote: "\uFF08 \u65E0\u9650 \uFF09",
110
110
  windows: {
111
111
  "5h": "5 \u5C0F\u65F6\u989D\u5EA6",
112
112
  week: "\u6BCF\u5468\u989D\u5EA6",
@@ -133,7 +133,7 @@ var COPY = {
133
133
  todayCalls: "Calls",
134
134
  weekUnlimited: "Weekly quota",
135
135
  unlimited: "\u267E\uFE0F",
136
- unlimitedNote: " (unlimited)",
136
+ unlimitedNote: " ( unlimited )",
137
137
  windows: {
138
138
  "5h": "5-hour quota",
139
139
  week: "Weekly quota",
@@ -170,9 +170,9 @@ var STYLE_TEXT = `
170
170
  .dqw-rail-trigger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, rgba(128,128,128,.12)); color: var(--dsw-alias-label-primary, inherit); }
171
171
  .dqw-rail-trigger:active:not(:disabled), .dqw-rail-trigger[aria-expanded="true"] { background: var(--dsw-alias-interactive-bg-active, rgba(128,128,128,.18)); color: var(--dsw-alias-label-primary, inherit); }
172
172
  .dqw-rail-trigger:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #5b8def); outline-offset: 2px; }
173
- [data-dsh-frame][data-sidebar-collapsed] [data-dsh-quota-watch-card] { display: flex; align-items: center; justify-content: center; width: 36px; margin: 0 0 12px; }
174
- [data-dsh-frame][data-sidebar-collapsed] [data-dsh-quota-watch-card] > .dqw-card { display: none; }
175
- [data-dsh-frame][data-sidebar-collapsed] [data-dsh-quota-watch-card] > .dqw-rail-trigger { display: inline-flex; }
173
+ [data-sidebar-collapsed] [data-dsh-quota-watch-card] { display: flex; align-items: center; justify-content: center; width: 36px; margin: 0 0 12px; }
174
+ [data-sidebar-collapsed] [data-dsh-quota-watch-card] > .dqw-card { display: none; }
175
+ [data-sidebar-collapsed] [data-dsh-quota-watch-card] > .dqw-rail-trigger { display: inline-flex; }
176
176
  .dqw-pop { position: fixed; z-index: 2147483000; min-width: 166px; max-width: 320px; padding: 10px 12px; border: 1px solid var(--dsw-alias-border-secondary, rgba(128,128,128,.35)); border-radius: 10px; background: var(--dsw-alias-bg-elevated, var(--dsw-alias-bg-base, #1f1f1f)); background: color-mix(in srgb, var(--dsw-alias-bg-base, #1f1f1f) 86%, transparent); -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3); box-shadow: 0 8px 24px rgba(0,0,0,.25); color: var(--dsw-alias-label-primary, inherit); display: flex; flex-direction: column; gap: 8px; font: inherit; }
177
177
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .dqw-pop { background: var(--dsw-alias-bg-elevated, var(--dsw-alias-bg-base, #1f1f1f)); } }
178
178
  .dqw-pop[hidden] { display: none; }
@@ -229,10 +229,16 @@ function formatTime(value, locale) {
229
229
  if (typeof value !== "string" || value === "") return "";
230
230
  const date = new Date(value);
231
231
  if (Number.isNaN(date.getTime())) return "";
232
- return new Intl.DateTimeFormat(locale === "zh" ? "zh-CN" : "en-US", {
233
- dateStyle: "short",
234
- timeStyle: "short"
235
- }).format(date);
232
+ const dateLocale = locale === "zh" ? "zh-CN" : "en-US";
233
+ const dateParts = new Intl.DateTimeFormat(dateLocale, {
234
+ year: "numeric",
235
+ month: "2-digit",
236
+ day: "2-digit"
237
+ }).formatToParts(date);
238
+ const part = (type) => dateParts.find((item) => item.type === type)?.value ?? "";
239
+ const dateText = `${part("year")}/${part("month")}/${part("day")}`;
240
+ const timeText = new Intl.DateTimeFormat(dateLocale, { timeStyle: "short" }).format(date);
241
+ return `${dateText} ${timeText}`;
236
242
  }
237
243
  function text(doc, tag, className, value) {
238
244
  const node = doc.createElement(tag);
@@ -535,7 +541,7 @@ function mountQuotaCard({
535
541
  wins.append(text(doc, "span", "dqw-win-mid", "\xB7"));
536
542
  wins.append(text(doc, "span", "dqw-win-used", copy.windowUsed));
537
543
  wins.append(text(doc, "span", "dqw-win-val", percent !== void 0 ? formatPercent(percent, locale) : "\u2014"));
538
- wins.append(text(doc, "span", "dqw-kv-sub", reset ? `\uFF08${copy.reset}: ${reset}\uFF09` : ""));
544
+ wins.append(text(doc, "span", "dqw-kv-sub", reset ? `\uFF08 ${copy.reset}: ${reset} \uFF09` : ""));
539
545
  }
540
546
  detail.append(wins);
541
547
  if (Array.isArray(usage?.models) && usage.models.length > 0) {
@@ -678,9 +684,9 @@ function mountQuotaCard({
678
684
  if (!disposed) place();
679
685
  });
680
686
  };
681
- let sidebarCollapsed = Boolean(doc.querySelector("[data-dsh-frame][data-sidebar-collapsed]"));
687
+ let sidebarCollapsed = Boolean(doc.querySelector("[data-sidebar-collapsed]"));
682
688
  const syncSidebarMode = () => {
683
- const nextCollapsed = Boolean(doc.querySelector("[data-dsh-frame][data-sidebar-collapsed]"));
689
+ const nextCollapsed = Boolean(doc.querySelector("[data-sidebar-collapsed]"));
684
690
  if (nextCollapsed === sidebarCollapsed) return;
685
691
  sidebarCollapsed = nextCollapsed;
686
692
  if (openKey !== void 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iasiv5/dsh-quota-watch",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "DSH Web sidebar monitor for GLM Coding Plan quotas and GitHub Copilot credits",
5
5
  "type": "module",
6
6
  "main": "./src/host.mjs",
package/src/client.mjs CHANGED
@@ -27,7 +27,7 @@ const COPY = {
27
27
  todayCalls: '调用次数',
28
28
  weekUnlimited: '每周额度',
29
29
  unlimited: '♾️',
30
- unlimitedNote: '(无限)',
30
+ unlimitedNote: '( 无限 )',
31
31
  windows: {
32
32
  '5h': '5 小时额度',
33
33
  week: '每周额度',
@@ -54,7 +54,7 @@ const COPY = {
54
54
  todayCalls: 'Calls',
55
55
  weekUnlimited: 'Weekly quota',
56
56
  unlimited: '♾️',
57
- unlimitedNote: ' (unlimited)',
57
+ unlimitedNote: ' ( unlimited )',
58
58
  windows: {
59
59
  '5h': '5-hour quota',
60
60
  week: 'Weekly quota',
@@ -92,9 +92,9 @@ const STYLE_TEXT = `
92
92
  .dqw-rail-trigger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, rgba(128,128,128,.12)); color: var(--dsw-alias-label-primary, inherit); }
93
93
  .dqw-rail-trigger:active:not(:disabled), .dqw-rail-trigger[aria-expanded="true"] { background: var(--dsw-alias-interactive-bg-active, rgba(128,128,128,.18)); color: var(--dsw-alias-label-primary, inherit); }
94
94
  .dqw-rail-trigger:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #5b8def); outline-offset: 2px; }
95
- [data-dsh-frame][data-sidebar-collapsed] [data-dsh-quota-watch-card] { display: flex; align-items: center; justify-content: center; width: 36px; margin: 0 0 12px; }
96
- [data-dsh-frame][data-sidebar-collapsed] [data-dsh-quota-watch-card] > .dqw-card { display: none; }
97
- [data-dsh-frame][data-sidebar-collapsed] [data-dsh-quota-watch-card] > .dqw-rail-trigger { display: inline-flex; }
95
+ [data-sidebar-collapsed] [data-dsh-quota-watch-card] { display: flex; align-items: center; justify-content: center; width: 36px; margin: 0 0 12px; }
96
+ [data-sidebar-collapsed] [data-dsh-quota-watch-card] > .dqw-card { display: none; }
97
+ [data-sidebar-collapsed] [data-dsh-quota-watch-card] > .dqw-rail-trigger { display: inline-flex; }
98
98
  .dqw-pop { position: fixed; z-index: 2147483000; min-width: 166px; max-width: 320px; padding: 10px 12px; border: 1px solid var(--dsw-alias-border-secondary, rgba(128,128,128,.35)); border-radius: 10px; background: var(--dsw-alias-bg-elevated, var(--dsw-alias-bg-base, #1f1f1f)); background: color-mix(in srgb, var(--dsw-alias-bg-base, #1f1f1f) 86%, transparent); -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3); box-shadow: 0 8px 24px rgba(0,0,0,.25); color: var(--dsw-alias-label-primary, inherit); display: flex; flex-direction: column; gap: 8px; font: inherit; }
99
99
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .dqw-pop { background: var(--dsw-alias-bg-elevated, var(--dsw-alias-bg-base, #1f1f1f)); } }
100
100
  .dqw-pop[hidden] { display: none; }
@@ -156,10 +156,16 @@ function formatTime(value, locale) {
156
156
  if (typeof value !== 'string' || value === '') return ''
157
157
  const date = new Date(value)
158
158
  if (Number.isNaN(date.getTime())) return ''
159
- return new Intl.DateTimeFormat(locale === 'zh' ? 'zh-CN' : 'en-US', {
160
- dateStyle: 'short',
161
- timeStyle: 'short',
162
- }).format(date)
159
+ const dateLocale = locale === 'zh' ? 'zh-CN' : 'en-US'
160
+ const dateParts = new Intl.DateTimeFormat(dateLocale, {
161
+ year: 'numeric',
162
+ month: '2-digit',
163
+ day: '2-digit',
164
+ }).formatToParts(date)
165
+ const part = (type) => dateParts.find((item) => item.type === type)?.value ?? ''
166
+ const dateText = `${part('year')}/${part('month')}/${part('day')}`
167
+ const timeText = new Intl.DateTimeFormat(dateLocale, { timeStyle: 'short' }).format(date)
168
+ return `${dateText} ${timeText}`
163
169
  }
164
170
 
165
171
  function text(doc, tag, className, value) {
@@ -488,7 +494,7 @@ export function mountQuotaCard({
488
494
  wins.append(text(doc, 'span', 'dqw-win-mid', '·'))
489
495
  wins.append(text(doc, 'span', 'dqw-win-used', copy.windowUsed))
490
496
  wins.append(text(doc, 'span', 'dqw-win-val', percent !== undefined ? formatPercent(percent, locale) : '—'))
491
- wins.append(text(doc, 'span', 'dqw-kv-sub', reset ? `(${copy.reset}: ${reset})` : ''))
497
+ wins.append(text(doc, 'span', 'dqw-kv-sub', reset ? `( ${copy.reset}: ${reset} )` : ''))
492
498
  }
493
499
  detail.append(wins)
494
500
  if (Array.isArray(usage?.models) && usage.models.length > 0) {
@@ -647,9 +653,9 @@ export function mountQuotaCard({
647
653
  })
648
654
  }
649
655
 
650
- let sidebarCollapsed = Boolean(doc.querySelector('[data-dsh-frame][data-sidebar-collapsed]'))
656
+ let sidebarCollapsed = Boolean(doc.querySelector('[data-sidebar-collapsed]'))
651
657
  const syncSidebarMode = () => {
652
- const nextCollapsed = Boolean(doc.querySelector('[data-dsh-frame][data-sidebar-collapsed]'))
658
+ const nextCollapsed = Boolean(doc.querySelector('[data-sidebar-collapsed]'))
653
659
  if (nextCollapsed === sidebarCollapsed) return
654
660
  sidebarCollapsed = nextCollapsed
655
661
  if (openKey !== undefined) {