← Commit history

one-capture surface flow (no per-poll consent spam)

John Lauer ·4b253bdac0 ·2mo ago ·parent 07643ed
1 file changed +10−20
web-control-demo.html+10−20
@@ -738,26 +738,16 @@ for (const w of mine) {   // modal dialog remains, then take the real capture. Errors fall through to a
   // direct capture so a bridge without includeImages support still renders.
   function settleThenCapture(c, stateCmd) {
-    var lastCount = -1, tries = 0;
-    function capture() { return postVerb(stateCmd, { maxWidth: 900 }); }
-    function poll() {
-      tries++;
-      return postVerb(stateCmd, { includeImages: false }).then(function (pr) {
-        var d = (pr.j && (pr.j.state || pr.j)) || {};
-        var shots = d.shots || d.windows || [];
-        var modals = d.modalDialogs || [];
-        var count = shots.length;
-        var settled = modals.length === 0 && count > 0 && count === lastCount;
-        lastCount = count;
-        if (settled || tries >= 8) {
-          if (!settled) clog(c, "  (capturing after " + tries + " polls without full settle)");
-          return capture();
-        }
-        if (modals.length) clog(c, "  waiting for a dialog to clear: " + modals.map(function (m) { return m.title || m; }).join(", "));
-        return new Promise(function (r) { setTimeout(r, 1500); }).then(poll);
-      }, capture);
-    }
-    return poll();
+    // ONE capture after a fixed settle delay - NO probe polling. The old loop
+    // polled the state verb up to 8x waiting for the window set to stabilize,
+    // and under an "Allow once" grant EVERY poll was its own consent prompt:
+    // John got NINE toasts for one screenshot (2026-08-17). Each cross-origin
+    // call costs one consent, so the page makes as few as possible. The
+    // bridges are being asked to own settle+capture inside the show verbs
+    // (capture:true) so this becomes zero extra calls.
+    clog(c, "  waiting ~3.5s for the surface to settle, then ONE capture ...");
+    return new Promise(function (r) { setTimeout(r, 3500); })
+      .then(function () { return postVerb(stateCmd, { maxWidth: 900 }); });
   }
 
   // summaries