Skip to content

Commit 48d04c1

Browse files
committed
mod: update ux-setup.js
1 parent 0e53764 commit 48d04c1

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

public/ux-setup.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* IsotopeAI — UX Setup Helper v1.4
3+
*
4+
* After a user signs in and the onboarding wizard opens, auto-advance
5+
* Steps 3-6 (preference pickers) so setup feels instant.
6+
*
7+
* Steps 1-2 (name + academic info) are left alone for the user to fill in.
8+
*
9+
* Nothing here touches auth, Supabase, or any Zustand store.
10+
*/
11+
(function () {
12+
'use strict';
13+
14+
function getCurrentStep() {
15+
var spans = document.querySelectorAll('span');
16+
for (var i = 0; i < spans.length; i++) {
17+
var m = spans[i].textContent.trim().match(/^(\d+)\/(\d+)$/);
18+
if (m) return { current: +m[1], total: +m[2] };
19+
}
20+
return null;
21+
}
22+
23+
function findNextBtn() {
24+
var keywords = ['next', 'continue', 'complete setup', "let's go", 'finish', 'get started'];
25+
var btns = Array.from(document.querySelectorAll('button:not([disabled])'));
26+
for (var i = 0; i < btns.length; i++) {
27+
if (keywords.indexOf(btns[i].textContent.trim().toLowerCase()) !== -1) return btns[i];
28+
}
29+
return null;
30+
}
31+
32+
function setReactValue(el, value) {
33+
try {
34+
var setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
35+
setter.call(el, value);
36+
el.dispatchEvent(new Event('input', { bubbles: true }));
37+
el.dispatchEvent(new Event('change', { bubbles: true }));
38+
} catch (_) {}
39+
}
40+
41+
function fillRequiredDefaults() {
42+
document.querySelectorAll('input[type="text"]:not([readonly])').forEach(function (inp) {
43+
if (inp.value.trim()) return;
44+
var ph = (inp.placeholder || '').toLowerCase();
45+
if (ph.includes('school') || ph.includes('institution')) setReactValue(inp, 'My School');
46+
else if (ph.includes('grade') || ph.includes('year')) setReactValue(inp, '12');
47+
});
48+
}
49+
50+
var _skipTimer = null;
51+
var _lastStep = -1;
52+
53+
function scheduleSkip(step) {
54+
if (step === _lastStep) return; // don't re-trigger same step
55+
_lastStep = step;
56+
clearTimeout(_skipTimer);
57+
_skipTimer = setTimeout(function () {
58+
if (!location.pathname.startsWith('/onboarding')) return;
59+
var s = getCurrentStep();
60+
if (!s || s.current < 3) return;
61+
fillRequiredDefaults();
62+
var nb = findNextBtn();
63+
if (nb) nb.click();
64+
}, 500);
65+
}
66+
67+
var _debounce = null;
68+
new MutationObserver(function () {
69+
clearTimeout(_debounce);
70+
_debounce = setTimeout(function () {
71+
if (!location.pathname.startsWith('/onboarding')) return;
72+
var s = getCurrentStep();
73+
if (s && s.current >= 3) scheduleSkip(s.current);
74+
}, 220);
75+
}).observe(document.body, { childList: true, subtree: true });
76+
77+
})();

0 commit comments

Comments
 (0)