Skill Tracer
Skills › Scientific Agent Skills › fictiv › list_dropdown_options.js

list_dropdown_options.js

48 lines · skills/fictiv/scripts/list_dropdown_options.js at 5f2bc03

1// List every option in the currently OPEN Fictiv dropdown (material, process,
2// finish color, thread size, ...).
3//
4// Fictiv uses Ant Design selects with a *virtualized* list: only ~8 options exist
5// in the DOM at a time, so reading the page text or a screenshot misses most of
6// them. Open the dropdown first (click the field), then run this in the browser's
7// javascript tool. It scrolls the list top-to-bottom and returns every option,
8// with category headers (e.g. "Aluminum", "Stereolithography (SLA)") marked "##".
9//
10// It only scrolls the list; it does not select anything.
11// Keep the leading `await`: the javascript tool returns the last expression's
12// value and does not unwrap a bare Promise (you'd get `{}`).
14await (async () => {
15 const holders = [...document.querySelectorAll(
16 '.ant-select-dropdown:not(.ant-select-dropdown-hidden) .rc-virtual-list-holder')];
17 const dropdowns = [...document.querySelectorAll('.ant-select-dropdown:not(.ant-select-dropdown-hidden)')];
18 if (!holders.length && !dropdowns.length) return 'No open dropdown. Click the select field first, then rerun.';
20 const seen = new Map();
21 const grab = (root) => root.querySelectorAll('.ant-select-item').forEach((it) => {
22 const label = it.innerText.trim();
23 if (!label || seen.has(label)) return;
24 const isGroup = it.classList.contains('ant-select-item-group');
25 seen.set(label, {
26 label,
27 group: isGroup,
28 disabled: it.classList.contains('ant-select-item-option-disabled'),
29 selected: it.classList.contains('ant-select-item-option-selected'),
30 });
31 });
33 const hold = holders[holders.length - 1];
34 if (hold) {
35 for (let y = 0; y <= hold.scrollHeight + 200; y += 80) {
36 hold.scrollTop = y;
37 await new Promise((r) => setTimeout(r, 100));
38 grab(hold);
39 }
40 hold.scrollTop = 0;
41 } else {
42 grab(dropdowns[dropdowns.length - 1]);
43 }
45 return [...seen.values()]
46 .map((o) => (o.group ? `## ${o.label}` : `${o.label}${o.selected ? ' [selected]' : ''}${o.disabled ? ' [disabled]' : ''}`))
47 .join('\n');
48})();