dsh-ustc-quota 1.1.27 → 1.1.28

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 (3) hide show
  1. package/client.js +32 -5
  2. package/index.js +1 -1
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -11,7 +11,7 @@ window.__ModuleLoader__.load({
11
11
  const UPDATE_ENDPOINT = 'plugins/dsh-ustc-quota/update';
12
12
  const UPDATE_APPLY_ENDPOINT = 'plugins/dsh-ustc-quota/update/apply';
13
13
  const WINDOW_IDS = ['3h', '12h', '24h'];
14
- const CLIENT_VERSION = '1.1.27';
14
+ const CLIENT_VERSION = '1.1.28';
15
15
  const UPDATE_INTERVAL_MS = 24 * 60 * 60 * 1000;
16
16
  const CLIENT_VERSION_KEY = `${NS}:client-version`;
17
17
  const CLIENT_RELOAD_KEY = `${NS}:client-reload`;
@@ -1173,7 +1173,19 @@ window.__ModuleLoader__.load({
1173
1173
  if (columnWidth - (width + DOCK_GAP * 2) < DOCK_TRANSCRIPT_FLOOR) {
1174
1174
  width = Math.max(DOCK_FLOOR_WIDTH, columnWidth - DOCK_TRANSCRIPT_FLOOR - DOCK_GAP * 2);
1175
1175
  }
1176
- const reserve = width + DOCK_GAP * 2;
1176
+ // A collapsed right sidebar keeps a narrow icon rail at the column's right edge;
1177
+ // the dock must stop before it, or it covers those native buttons.
1178
+ let railInset = 0;
1179
+ for (const button of document.querySelectorAll('button[aria-label]')) {
1180
+ const label = button.getAttribute('aria-label') || '';
1181
+ if (!/右侧边栏/.test(label)) continue;
1182
+ const rect = button.getBoundingClientRect();
1183
+ if (rect.width <= 0 || rect.height <= 0) continue;
1184
+ const inset = Math.round(columnRect.right - rect.left);
1185
+ if (inset > 0 && inset < Math.round(columnRect.width * 0.3)) railInset = Math.max(railInset, inset);
1186
+ }
1187
+ width = Math.max(DOCK_FLOOR_WIDTH, width - railInset);
1188
+ const reserve = width + railInset + DOCK_GAP * 2;
1177
1189
 
1178
1190
  // Vertical bound: never cross or touch the separator under the tab strip.
1179
1191
  let contentTop = Math.round(columnRect.top) + DOCK_GAP;
@@ -1218,13 +1230,14 @@ window.__ModuleLoader__.load({
1218
1230
  }
1219
1231
  return { count, left: min === null ? null : Math.round(min) };
1220
1232
  })(),
1221
- dock: { width, reserve, top: contentTop },
1233
+ dock: { width, reserve, top: contentTop, railInset },
1222
1234
  viewport: window.innerWidth,
1223
1235
  });
1224
1236
  return {
1225
1237
  top: contentTop,
1226
1238
  width,
1227
1239
  reserve,
1240
+ railInset,
1228
1241
  maxHeight: Math.max(120, Math.round(columnRect.bottom) - contentTop - DOCK_GAP),
1229
1242
  };
1230
1243
  }
@@ -1270,8 +1283,22 @@ window.__ModuleLoader__.load({
1270
1283
  if (!column) return undefined;
1271
1284
  const saved = column.style.getPropertyValue('padding-right');
1272
1285
  const priority = column.style.getPropertyPriority('padding-right');
1273
- column.style.setProperty('padding-right', reserve + 'px', 'important');
1286
+ const wanted = reserve + 'px';
1287
+ const apply = () => {
1288
+ if (column.style.getPropertyValue('padding-right') !== wanted) {
1289
+ column.style.setProperty('padding-right', wanted, 'important');
1290
+ }
1291
+ };
1292
+ apply();
1293
+ // DSH re-renders the column and rewrites its style attribute, so watch it.
1294
+ const observer = typeof MutationObserver === 'function'
1295
+ ? new MutationObserver(apply)
1296
+ : null;
1297
+ if (observer) observer.observe(column, { attributes: true, attributeFilter: ['style'] });
1298
+ const timer = window.setInterval(apply, 1000);
1274
1299
  return () => {
1300
+ if (observer) observer.disconnect();
1301
+ window.clearInterval(timer);
1275
1302
  if (saved) column.style.setProperty('padding-right', saved, priority);
1276
1303
  else column.style.removeProperty('padding-right');
1277
1304
  };
@@ -1282,7 +1309,7 @@ window.__ModuleLoader__.load({
1282
1309
  style: {
1283
1310
  position: 'fixed',
1284
1311
  top: box ? box.top : 0,
1285
- right: DOCK_GAP,
1312
+ right: DOCK_GAP + (box ? box.railInset : 0),
1286
1313
  width: box ? box.width : DOCK_MIN_WIDTH,
1287
1314
  maxHeight: box ? box.maxHeight : 0,
1288
1315
  overflow: 'visible',
package/index.js CHANGED
@@ -25,7 +25,7 @@ const ROUTE_PATH = '/plugins/dsh-ustc-quota/snapshot';
25
25
  const UPDATE_PATH = '/plugins/dsh-ustc-quota/update';
26
26
  const UPDATE_APPLY_PATH = '/plugins/dsh-ustc-quota/update/apply';
27
27
  const UPDATE_TOKEN_TTL_MS = 30 * 60 * 1000;
28
- const PLUGIN_VERSION = '1.1.27';
28
+ const PLUGIN_VERSION = '1.1.28';
29
29
  const KEY_INFO_PATH = 'key/info';
30
30
  const USER_INFO_PATH = 'user/info';
31
31
  const DISCOVERY_TTL_MS = 30000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ustc-quota",
3
- "version": "1.1.27",
3
+ "version": "1.1.28",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Live 3h/12h/24h USTC token quota card in the DSH sidebar (works with the USTC TokenWorks distribution).",