Something went wrong. Try again.
small gleam coding and (not yet) persistent agent daemon with a detachable cli forked from okami.mom/albedo
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051"""Small page-side functions; values cross the boundary, not live JS handles."""
STATE = r"""function() { const e = this.nodeType === 1 ? this : this.parentElement; if (!e || !e.isConnected) return {connected:false}; const r = e.getBoundingClientRect(), s = getComputedStyle(e); return {connected:true, tag:e.tagName.toLowerCase(), type:e.type || '', disabled:!!e.disabled || e.getAttribute('aria-disabled') === 'true', readonly:!!e.readOnly || e.getAttribute('aria-readonly') === 'true', editable:e.isContentEditable, visible:r.width > 0 && r.height > 0 && s.visibility === 'visible' && s.display !== 'none' && Number(s.opacity) !== 0, width:r.width, height:r.height};}"""
CONTAINS = r"""function(hit) { const e = this.nodeType === 1 ? this : this.parentElement; for (let n = hit; n; n = n.parentNode || n.host) if (n === e) return true; return false;}"""
SELECT_TEXT = r"""function() { this.focus(); if (this.getRootNode().activeElement !== this) return false; if (typeof this.select === 'function') this.select(); else if (this.isContentEditable) { const range = this.ownerDocument.createRange(); range.selectNodeContents(this); const sel = this.ownerDocument.getSelection(); sel.removeAllRanges(); sel.addRange(range); } else return false; return true;}"""
READ_VALUE = ( r"""function() { return this.isContentEditable ? this.textContent : this.value; }""")
SELECT_OPTION = r"""function(want) { const options = Array.from(this.options || []); const option = options.find(o => o.value === want) || options.find(o => o.label.trim() === want || o.text.trim() === want); if (!option || option.disabled) return {found: false, available: options.map(o => o.value).slice(0, 20)}; if (this.multiple) { for (const o of options) o.selected = o === option; } else { this.value = option.value; } if (!option.selected) return {found: false, available: options.map(o => o.value).slice(0, 20)}; this.dispatchEvent(new Event('input', {bubbles: true})); this.dispatchEvent(new Event('change', {bubbles: true})); return {found: true, value: option.value, label: option.label.trim()};}"""