From 5c03573658857dcda0327905508b7b723618a033 Mon Sep 17 00:00:00 2001 From: ch <1938389+netravnen@users.noreply.github.com> Date: Thu, 20 Aug 2026 12:57:32 +0200 Subject: [PATCH] fix(fp): resolve dormant code and adopt lifecycle markers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Applies what remains of the ratified fp triage now that the write-guard work has landed on dev-next. An earlier draft of this change staged FP's exclusion cluster as planned safety code with `@staged wip` markers; that cluster is now live upstream -- wired into the IX-F netixlan write paths and shared via lib/admincom-entity-exclusions.js -- and under the ratified @staged grammar (markers only on unreferenced symbols) staging no longer applies, so those markers are dropped here rather than carried. What remains are the orphan deletions and the tree's first @deprecated adopters under the frozen grammar. Changes: - Delete groupCustomItemsByVisualRow (orphaned by the 7169919 toolbar refactor). - Delete the dead `members` array population in copy-user-roles; the admins-only clipboard output is byte-identical. - Delete FP's unused buildTampermonkeyRequestHeaders copy -- the identical body survives in CP and DP, and a hoped-for lib extraction is not a planned FP feature. - Convert LEGACY_API_PAYLOAD_CACHE_STORAGE_PREFIX and LEGACY_API_PAYLOAD_TAB_CACHE_STORAGE_PREFIX to the frozen `@deprecated — ` line-comment form, preserving the migrateLegacyApiPayloadCacheKeys() sweep prose. - Bump FP @version to 1.1.42 (src + meta); regenerate .user.js. Testing: - Full suite green: 585 pass, 0 fail (1 pre-existing skip). - build --check and node --check on the regenerated .user.js: clean. - Verified by grep across all five source files + tests/ that zero references remain to groupCustomItemsByVisualRow, buildTampermonkeyRequestHeaders (FP copy) and the members array. Backwards Compatibility: - copy-user-roles output unchanged (admins joined by newline). - No live user-facing behavior changes; deleted code had no caller. Assisted-by: Claude:claude-opus-5 Assisted-by: Claude:claude-fable-5 --- .../peeringdb-fp-consolidated-tools.meta.js | 2 +- .../peeringdb-fp-consolidated-tools.src.js | 60 +++---------------- .../peeringdb-fp-consolidated-tools.user.js | 60 +++---------------- 3 files changed, 15 insertions(+), 107 deletions(-) diff --git a/user.js/peeringdb-fp-consolidated-tools.meta.js b/user.js/peeringdb-fp-consolidated-tools.meta.js index 9141da7..f1f2643 100644 --- a/user.js/peeringdb-fp-consolidated-tools.meta.js +++ b/user.js/peeringdb-fp-consolidated-tools.meta.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PeeringDB FP - Consolidated Tools // @namespace https://www.peeringdb.com/ -// @version 1.1.41 +// @version 1.1.42 // @description Consolidated FP userscript for PeeringDB frontend (Net/Org/Fac/IX/Carrier) // @author // @match https://www.peeringdb.com/* diff --git a/user.js/peeringdb-fp-consolidated-tools.src.js b/user.js/peeringdb-fp-consolidated-tools.src.js index fbbf364..b7ef77a 100644 --- a/user.js/peeringdb-fp-consolidated-tools.src.js +++ b/user.js/peeringdb-fp-consolidated-tools.src.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PeeringDB FP - Consolidated Tools // @namespace https://www.peeringdb.com/ -// @version 1.1.41 +// @version 1.1.42 // @description Consolidated FP userscript for PeeringDB frontend (Net/Org/Fac/IX/Carrier) // @author // @match https://www.peeringdb.com/* @@ -95,9 +95,13 @@ // mechanism so re-verifying a row, or verifying a second row at the same // exchange, doesn't re-fetch it. const IXF_EXPORT_CACHE_TTL_MS = 15 * 60 * 1000; - // Legacy per-script cache key prefixes -- no longer written to; kept only - // so migrateLegacyApiPayloadCacheKeys() can sweep and remove old entries once. + // @deprecated — legacy per-script cache key prefixes, no longer written to; kept only so + // migrateLegacyApiPayloadCacheKeys() can sweep and remove old entries once; delete after the + // sweep has shipped long enough that no installs still hold pre-migration entries. const LEGACY_API_PAYLOAD_CACHE_STORAGE_PREFIX = `${MODULE_PREFIX}.apiPayloadCache.`; + // @deprecated — legacy per-script cache key prefixes, no longer written to; kept only so + // migrateLegacyApiPayloadCacheKeys() can sweep and remove old entries once; delete after the + // sweep has shipped long enough that no installs still hold pre-migration entries. const LEGACY_API_PAYLOAD_TAB_CACHE_STORAGE_PREFIX = `${MODULE_PREFIX}.apiPayloadTabCache.`; /* @include admincom-entity-exclusions.js */ @@ -536,25 +540,6 @@ lastFetchFailureByUrl.delete(key); } - /** - * Constructs HTTP headers for Tampermonkey requests with User-Agent. - * Purpose: Centralize header building for all script-initiated requests. - * Necessity: Ensures consistent User-Agent and other important headers across all API calls. - */ - function buildTampermonkeyRequestHeaders(baseHeaders = {}) { - const headers = { ...baseHeaders }; - const userAgent = getCustomRequestUserAgent(); - - if (userAgent) { - headers["User-Agent"] = userAgent; - if (!headers["X-PDB-Request-UA"] && !headers["x-pdb-request-ua"]) { - headers["X-PDB-Request-UA"] = userAgent; - } - } - - return headers; - } - /** * Installs lightweight fetch instrumentation for debug diagnostics. */ @@ -2150,35 +2135,6 @@ host.style.display = row1.children.length || row2.children.length ? "flex" : "none"; } - /** - * Groups custom toolbar items by vertical pixel position (visual rows). - * Purpose: Detect which buttons wrap to new lines due to narrow viewports. - * Necessity: Understand natural wrapping behavior for spacing adjustments. - */ - function groupCustomItemsByVisualRow(customItems, topTolerance = 3) { - const rows = []; - - customItems.forEach((item) => { - const top = item.offsetTop; - let row = rows.find((entry) => Math.abs(entry.top - top) <= topTolerance); - - if (!row) { - row = { top, items: [] }; - rows.push(row); - } - - row.items.push(item); - row.top = Math.min(row.top, top); - }); - - rows.sort((a, b) => a.top - b.top); - rows.forEach((row) => { - row.items.sort((a, b) => a.offsetLeft - b.offsetLeft); - }); - - return rows; - } - /** * Removes individual button margins to rely on container gap for spacing. * Purpose: Standardize spacing through flexbox gap instead of element margins. @@ -3768,7 +3724,6 @@ btn.addEventListener("click", () => { void withActionLock("copy-user-roles", async () => { const admins = []; - const members = []; const currentUsers = qsa( '#org-user-manager > div[data-edit-template="user-item"] > .editable' @@ -3792,7 +3747,6 @@ ?.getAttribute("data-edit-value"); if (role === "admin") admins.push(email); - if (role === "member") members.push(email); }); // Legacy script only returned admins joined by newline diff --git a/user.js/peeringdb-fp-consolidated-tools.user.js b/user.js/peeringdb-fp-consolidated-tools.user.js index 86229e4..c9cdea9 100644 --- a/user.js/peeringdb-fp-consolidated-tools.user.js +++ b/user.js/peeringdb-fp-consolidated-tools.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PeeringDB FP - Consolidated Tools // @namespace https://www.peeringdb.com/ -// @version 1.1.41 +// @version 1.1.42 // @description Consolidated FP userscript for PeeringDB frontend (Net/Org/Fac/IX/Carrier) // @author // @match https://www.peeringdb.com/* @@ -95,9 +95,13 @@ // mechanism so re-verifying a row, or verifying a second row at the same // exchange, doesn't re-fetch it. const IXF_EXPORT_CACHE_TTL_MS = 15 * 60 * 1000; - // Legacy per-script cache key prefixes -- no longer written to; kept only - // so migrateLegacyApiPayloadCacheKeys() can sweep and remove old entries once. + // @deprecated — legacy per-script cache key prefixes, no longer written to; kept only so + // migrateLegacyApiPayloadCacheKeys() can sweep and remove old entries once; delete after the + // sweep has shipped long enough that no installs still hold pre-migration entries. const LEGACY_API_PAYLOAD_CACHE_STORAGE_PREFIX = `${MODULE_PREFIX}.apiPayloadCache.`; + // @deprecated — legacy per-script cache key prefixes, no longer written to; kept only so + // migrateLegacyApiPayloadCacheKeys() can sweep and remove old entries once; delete after the + // sweep has shipped long enough that no installs still hold pre-migration entries. const LEGACY_API_PAYLOAD_TAB_CACHE_STORAGE_PREFIX = `${MODULE_PREFIX}.apiPayloadTabCache.`; // >>> GENERATED by user.js/scripts/build_userscripts.py from peeringdb-fp-consolidated-tools.src.js + lib/admincom-entity-exclusions.js <<< @@ -1032,25 +1036,6 @@ lastFetchFailureByUrl.delete(key); } - /** - * Constructs HTTP headers for Tampermonkey requests with User-Agent. - * Purpose: Centralize header building for all script-initiated requests. - * Necessity: Ensures consistent User-Agent and other important headers across all API calls. - */ - function buildTampermonkeyRequestHeaders(baseHeaders = {}) { - const headers = { ...baseHeaders }; - const userAgent = getCustomRequestUserAgent(); - - if (userAgent) { - headers["User-Agent"] = userAgent; - if (!headers["X-PDB-Request-UA"] && !headers["x-pdb-request-ua"]) { - headers["X-PDB-Request-UA"] = userAgent; - } - } - - return headers; - } - /** * Installs lightweight fetch instrumentation for debug diagnostics. */ @@ -2646,35 +2631,6 @@ host.style.display = row1.children.length || row2.children.length ? "flex" : "none"; } - /** - * Groups custom toolbar items by vertical pixel position (visual rows). - * Purpose: Detect which buttons wrap to new lines due to narrow viewports. - * Necessity: Understand natural wrapping behavior for spacing adjustments. - */ - function groupCustomItemsByVisualRow(customItems, topTolerance = 3) { - const rows = []; - - customItems.forEach((item) => { - const top = item.offsetTop; - let row = rows.find((entry) => Math.abs(entry.top - top) <= topTolerance); - - if (!row) { - row = { top, items: [] }; - rows.push(row); - } - - row.items.push(item); - row.top = Math.min(row.top, top); - }); - - rows.sort((a, b) => a.top - b.top); - rows.forEach((row) => { - row.items.sort((a, b) => a.offsetLeft - b.offsetLeft); - }); - - return rows; - } - /** * Removes individual button margins to rely on container gap for spacing. * Purpose: Standardize spacing through flexbox gap instead of element margins. @@ -4264,7 +4220,6 @@ btn.addEventListener("click", () => { void withActionLock("copy-user-roles", async () => { const admins = []; - const members = []; const currentUsers = qsa( '#org-user-manager > div[data-edit-template="user-item"] > .editable' @@ -4288,7 +4243,6 @@ ?.getAttribute("data-edit-value"); if (role === "admin") admins.push(email); - if (role === "member") members.push(email); }); // Legacy script only returned admins joined by newline