Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

Add brief nucleus animation to selection More button

Emre Sokulluc949f04f1810
diff --git a/dist/webbrain-chrome-42.4.3.zip b/dist/webbrain-chrome-42.4.3.zip
index aee4b1a3e..a8f7bf8a3 100644
Binary files a/dist/webbrain-chrome-42.4.3.zip and b/dist/webbrain-chrome-42.4.3.zip differ
diff --git a/dist/webbrain-edge-42.4.3.zip b/dist/webbrain-edge-42.4.3.zip
index bcabf657f..1d75160b6 100644
Binary files a/dist/webbrain-edge-42.4.3.zip and b/dist/webbrain-edge-42.4.3.zip differ
diff --git a/dist/webbrain-firefox-42.4.3.zip b/dist/webbrain-firefox-42.4.3.zip
index d57f34ea3..7e2bda405 100644
Binary files a/dist/webbrain-firefox-42.4.3.zip and b/dist/webbrain-firefox-42.4.3.zip differ
diff --git a/src/chrome/src/content/selection-shortcut.js b/src/chrome/src/content/selection-shortcut.js
index e8fb5c98b..d5dac3f9b 100644
--- a/src/chrome/src/content/selection-shortcut.js
+++ b/src/chrome/src/content/selection-shortcut.js
@@ -83,6 +83,7 @@
let highlightLayer = null;
let shortcut = null;
let moreButton = null;
+ let moreBrain = null;
let popup = null;
let question = null;
let includePageContext = null;
@@ -107,6 +108,182 @@
return Math.max(min, Math.min(max, value));
}
+ // The small Nucleus mark and orbit renderer from assets/loader-candidates/.
+ // Play two orbits on reveal, then leave only the monochrome mark.
+ function mountMoreBrain(canvas) {
+ let ctx = null;
+ try { ctx = canvas?.getContext('2d'); } catch { /* More remains usable without canvas. */ }
+ if (!ctx || typeof Path2D !== 'function') return { play() {}, destroy() {} };
+ const mark = new Path2D('M46.6 93.2C46 92.7 45.5 91.5 45 89.6C44.6 87.9 44 86 43.7 85.2C42.8 83.1 42.9 82.9 44.7 81.9C45.6 81.4 47.2 80.2 48.2 79.3L50 77.6L51.5 78.9C52.2 79.7 53.7 80.8 54.7 81.5C57.1 83.1 57.1 83.3 56.2 85.6C55.8 86.7 55.2 88.6 55 89.9C54.3 93.2 53.5 93.8 50 93.8C48.1 93.8 47.2 93.7 46.6 93.2ZM26.6 81.8C24.1 80.9 21.6 79.3 20.6 77.8C19.2 75.8 19.3 75.5 21.5 75.2C23.4 75 26.9 73.1 26.9 72.3C26.9 72 26.5 71.9 25.7 72.1C19.4 73.3 16 72 14.6 67.9C14.4 67.1 14 66.5 13.8 66.5C12.5 66.5 13.1 69.9 14.8 72.1C16.3 74 16.1 74.1 13.2 73.3C3.5 70.4 5.5 55.2 15.3 57.3C17.9 57.8 18 57.1 15.7 55.9C11.7 53.8 5.8 56.7 4.5 61.4C4 63.3 3.8 63.4 3 62.4C-0.1 59 -0 50.7 3.1 47.9C3.7 47.3 3.8 47.4 4.4 48.3C5.3 49.7 5.9 49.5 5.6 47.7C5.3 46 5.9 43.5 6.9 42.2C7.8 41 7.9 40.8 7.2 40.8C6.7 40.8 5.1 42.3 3.4 44.5C1.6 46.9 1.6 40.5 3.4 37C4.5 35 5.3 34.1 7.1 32.9C8.4 32 8.5 31.8 8.6 29.9C8.7 27.1 10.4 23.9 12.6 21.9C17.9 17.2 29 17.5 28.9 22.2C28.9 25.5 28.5 26.4 26.8 26.7C24 27.2 22.9 28.5 25.3 28.5C28.7 28.5 31.2 31.5 31.2 35.6C31.2 39 31.7 40.2 34.2 42.9C37.2 46.1 38.1 49 36.7 52.2C36.2 53.5 36.2 53.6 36.8 54.3C37.8 55.4 37.8 55.4 41.5 48.4C46.3 39.5 47.7 38.2 51.5 39.2C53.7 39.8 54.6 40.9 58.3 48C62 55 62.2 55.3 63.2 54.3C63.8 53.7 63.8 53.5 63.3 52.2C61.9 49 62.7 46.3 66 42.7C67.3 41.2 68.5 40 68.5 39.9C68.5 39.9 68.7 38.1 68.8 36.1C69.2 31 70.7 29 74.4 28.6C75.4 28.4 76.2 28.2 76.2 27.9C76.2 27.4 73.7 26.5 72.4 26.5C71.8 26.5 71.5 26.3 71.5 25.6C71.5 25.1 71.4 24.2 71.1 23.6C70.4 21.4 73 18.5 75.7 18.5C76.9 18.5 77.1 17.7 76.1 17.4C74.8 16.9 72 17.6 70.6 18.6L69.3 19.6L67.6 17.9C65.8 16.3 62.9 14.7 62.4 15.1C62.3 15.2 63.2 16.3 64.4 17.4C68.3 20.9 70.1 26.3 68.3 29L67.6 30.1L66.7 29.2C65.4 28 65 28.6 65.8 30.3C66.4 31.5 66.5 32.2 66.2 35.2C65.9 39.4 65.3 40.5 62.8 41.6C61.6 42.1 61.2 42.5 61.3 42.9C61.4 43.3 61.3 44 60.9 44.7L60.3 45.9L58.8 43C57 39.7 55.4 37.9 53.4 36.9C51.8 36.1 51.5 35.6 51.5 33.1C51.6 30.9 52.3 29.9 54.7 28.9C57 27.9 56.8 27.1 54.5 27.4C53.6 27.5 52.6 27.7 52.2 27.9C51.7 28.1 51.6 27.8 51.3 26C50.8 21.8 51.6 20 54.5 19C57.1 18.1 56.3 17.1 53.5 17.7C51.3 18.2 51.4 18.3 51.4 13.9C51.4 8.8 51.6 8.3 53.6 7.2C57.4 5.2 64.6 6.5 67.2 9.8C68.2 11.1 68.3 11.2 71 11.2C75.5 11.2 78.7 13.2 80.4 17C81 18.5 81.4 18.9 82.5 19.2C87 20.4 90.5 24.4 91.4 29C91.6 30.1 91.5 30.5 91 30.9C90.4 31.4 90.5 31.5 92.4 32.6C94.5 33.8 96.2 35.7 97.2 38.2C97.9 39.7 98.2 43.9 97.8 44.5C97.4 45.2 96.3 44.8 96 43.9C95.7 42.9 93.1 40.6 92.8 40.9C92.7 41.1 92.7 41.5 93 41.8C94 43.2 94.4 44.5 94.5 46.7C94.5 48 94.6 49.1 94.6 49.2C94.6 49.3 95.1 48.9 95.6 48.3C96.5 47.2 96.5 47.1 97.1 47.9C99.5 50.9 100.1 56.1 98.5 59.9C97.4 62.4 96.3 63.5 95.9 62.5C94.9 59.1 93.4 57.3 91 56.1C89 55 85.9 55 84.2 56C82.8 56.8 82.6 57.6 83.8 57.4C89.5 56.3 93.1 59 93.1 64.5C93.1 68.9 90.9 72.1 86.9 73.3C83.9 74.1 83.6 74 84.8 72.6C86.1 71.1 86.9 69.2 86.9 67.9C86.9 66.4 86.2 66.4 85.6 67.8C83.8 72.1 80.4 73.4 74.3 72.1C73.6 71.9 73.1 72 73.1 72.2C73.1 73 76.7 75 78.5 75.2C80.6 75.5 80.8 75.9 79.5 77.7C74.1 85.7 54.2 82.4 51.4 73C51 71.9 50.8 70.5 50.8 70C50.8 67.3 49.4 68.3 49.1 71.2C48.4 77.4 41.7 81.7 32.1 82.1C29.5 82.3 27.8 82.1 26.6 81.8ZM34.5 78.6C36 78 37.7 76.7 37.7 76.1C37.7 75.5 36.2 75.8 34 76.9C32.8 77.6 31.4 78.1 30.8 78.1C29.7 78.1 29 78.5 29.5 79C30 79.4 33.1 79.2 34.5 78.6ZM70.5 78.7C70.5 78.4 69.7 78.1 68.9 78C68 77.9 66.5 77.3 65.4 76.7C63.2 75.4 61.7 75.6 62.9 77C64.5 78.8 70.8 80.1 70.5 78.7ZM40.9 69.4C42.2 69.1 43.8 68.8 44.4 68.8C45.3 68.7 45.6 68.5 45.5 67.9C45.4 67.4 45.9 66.1 46.6 64.9C47.3 63.8 48.3 61.9 48.8 60.8C50.1 58.3 50 58.3 51.6 61.6C52.3 63.1 53.3 65 53.9 65.8C54.6 66.7 54.8 67.4 54.6 67.7C54.1 68.5 54.5 68.8 56.2 68.8C57 68.8 58.1 69 58.4 69.2C59.7 69.9 63.2 70.1 65 69.6C66.4 69.3 67.3 68.6 69.6 66.1C72.6 63 73.8 62.3 76.4 62.3C78.2 62.3 78 61.6 75.9 60.7C74.2 60 74.2 59.9 74.5 58.5C75.4 53.5 77.8 51.1 82.7 50C85 49.6 87.9 47.9 88.3 47C88.6 46.1 88.2 46 86.9 46.8C85.7 47.4 79.2 48.6 78.9 48.2C78.2 47.5 81.7 40.9 84 38.7C87.6 35.3 87.9 31.3 84.8 28.5C83.7 27.4 83.2 27.6 83.9 28.9C85.3 31.6 84.1 35.5 81.2 37.2C79.4 38.4 79.3 38.5 76.7 44.7C68.2 65.1 67.1 66.9 62.1 66.9C58.2 66.9 56.9 65.6 53 58C51.6 55.1 50.2 52.7 50 52.7C49.8 52.7 48.3 55.5 46.5 58.8C42.9 65.9 42.2 66.6 38.3 66.8C33.4 67.1 32.2 65.5 25.5 50L20.6 38.4L18.6 37.1C15.9 35.3 15.1 32.4 16.3 28.6C16.8 27.2 15.9 27.5 14.6 29.3C12.2 32.6 12.9 36.2 16.4 39.1C18.2 40.6 21.8 47.6 21.1 48.2C20.8 48.5 14.3 47.4 13.2 46.8C10.7 45.5 11.6 47.3 14.2 49C14.8 49.3 16.2 49.8 17.3 50C21.5 50.9 23.3 52.3 24.8 56.1C26.1 59.2 26.1 60.2 24.7 60.6C21.7 61.3 21.9 62.1 25.2 62.5C27 62.7 27.3 63 29.8 65.6C34 69.9 36 70.6 40.9 69.4ZM39.1 44.8C38.8 44.1 38.6 43.3 38.6 43C38.6 42.6 38 42 36.9 41.5C34.5 40.2 33.9 39 33.8 34.8C33.7 32.2 33.8 31 34.3 30.1C35.1 28.6 34.7 28.2 33.3 29.2L32.3 30L31.7 29C29.9 26.3 31.8 20.8 35.6 17.4C37 16.2 37.6 15.4 37.3 15.2C36.8 14.9 32.9 17.2 31.7 18.6L30.8 19.7L29.5 18.7C27.8 17.5 26.1 16.9 22.8 16.7C19.7 16.4 19.6 16.3 21 14.6C22.9 12.4 25.1 11.4 28.7 11.2C31.8 11.1 31.9 11 32.9 9.8C36.1 5.5 46.9 5 48.5 9.1C48.9 10.3 49 17.6 48.5 17.8C48.4 17.9 47.6 17.9 46.7 17.7C45.8 17.5 45 17.5 44.5 17.7C43.6 18.2 43.9 18.7 45.3 19C48.2 19.5 49.5 22.6 48.7 26.7C48.5 28 48.3 28.1 47.6 27.8C46.3 27.4 44.1 27.4 44 27.9C43.9 28.1 44.7 28.7 45.8 29.1C49.1 30.5 50 35 47.2 36.5C44.9 37.7 43.1 39.7 41.4 42.8L39.7 45.9L39.1 44.8Z');
+ const size = 22;
+ const tau = Math.PI * 2;
+ const duration = 2000;
+ const radius = size * 0.44;
+ const markPx = size * 0.62;
+ const samples = 10;
+ const motion = window.matchMedia('(prefers-reduced-motion: reduce)');
+ const theme = window.matchMedia('(prefers-color-scheme: dark)');
+ const mono = (value) => [value, value, value];
+ const rgba = (color, alpha) => `rgba(${color.join(',')},${clamp(alpha, 0, 1)})`;
+ let scale = 1;
+ let palette;
+ let frame = 0;
+ let startedAt = 0;
+
+ function restyle() {
+ scale = clamp(window.devicePixelRatio || 1, 1, 4);
+ canvas.width = canvas.height = Math.round(size * scale);
+ const rgb = getComputedStyle(moreButton).color.match(/[\d.]+/g)?.slice(0, 3).map(Number) || [23, 23, 23];
+ const ink = Math.round(rgb[0] * 0.2126 + rgb[1] * 0.7152 + rgb[2] * 0.0722);
+ const dark = ink > 128;
+ palette = { dark, ink: mono(ink), glow: mono(dark ? ink * 0.8 : ink + 60), hot: mono(dark ? 255 : ink) };
+ }
+
+ function markTransform() {
+ ctx.translate((size - markPx) / 2, (size - markPx) / 2);
+ ctx.scale(markPx / 100, markPx / 100);
+ }
+
+ function drawMark() {
+ ctx.globalCompositeOperation = 'source-over';
+ ctx.save();
+ markTransform();
+ ctx.fillStyle = rgba(palette.ink, 1);
+ ctx.fill(mark, 'evenodd');
+ ctx.restore();
+ }
+
+ function clear() {
+ ctx.setTransform(scale, 0, 0, scale, 0, 0);
+ ctx.clearRect(0, 0, size, size);
+ }
+
+ function glowDot(point, color, alpha) {
+ const r = 2.1 * (palette.dark ? 1.3 : 1.05);
+ const gradient = ctx.createRadialGradient(point[0], point[1], 0, point[0], point[1], r);
+ gradient.addColorStop(0, rgba(color, alpha));
+ gradient.addColorStop(0.25, rgba(palette.glow, alpha * 0.7));
+ gradient.addColorStop(1, rgba(palette.glow, 0));
+ ctx.fillStyle = gradient;
+ ctx.beginPath();
+ ctx.arc(point[0], point[1], r, 0, tau);
+ ctx.fill();
+ }
+
+ const depthAlpha = (z) => z < 0 ? 0.3 + 0.42 * (1 + z) : 0.86 + 0.14 * z;
+ const depthWidth = (z) => z < 0 ? 0.76 + 0.16 * (1 + z) : 1 + 0.22 * z;
+
+ // Tapered ribbons, with the same depth split as the original Nucleus.
+ function ribbon(points, start, end, overMark) {
+ if (end <= start) return;
+ const left = [], right = [];
+ for (let i = start; i <= end; i++) {
+ const before = points[Math.max(0, i - 1)], after = points[Math.min(samples, i + 1)];
+ const length = Math.hypot(after[0] - before[0], after[1] - before[1]) || 1;
+ const width = (1.5 * Math.pow(1 - i / samples, 0.8) + 0.3) * depthWidth(points[i][2]) / 2;
+ const nx = -(after[1] - before[1]) / length * width;
+ const ny = (after[0] - before[0]) / length * width;
+ left.push([points[i][0] + nx, points[i][1] + ny]);
+ right.push([points[i][0] - nx, points[i][1] - ny]);
+ }
+ ctx.beginPath();
+ left.forEach(([x, y], i) => i ? ctx.lineTo(x, y) : ctx.moveTo(x, y));
+ for (let i = right.length - 1; i >= 0; i--) ctx.lineTo(...right[i]);
+ ctx.closePath();
+ const gradient = ctx.createLinearGradient(...points[start].slice(0, 2), ...points[end].slice(0, 2));
+ for (const offset of [0, 0.5, 1]) {
+ const i = Math.round(start + (end - start) * offset);
+ const u = i / samples;
+ const color = overMark ? palette.glow : palette.hot.map((value, k) => Math.round(value + (palette.glow[k] - value) * Math.min(1, u * 1.7)));
+ gradient.addColorStop(offset, rgba(color, Math.pow(1 - u, 1.5) * depthAlpha(points[i][2]) * 0.95));
+ }
+ ctx.fillStyle = gradient;
+ ctx.fill();
+ }
+
+ function drawSpark(points, front, overMark = false) {
+ let start = -1;
+ for (let i = 0; i < samples; i++) {
+ const isFront = (points[i][2] + points[i + 1][2]) / 2 >= 0;
+ if (isFront === front && start < 0) start = i;
+ if ((isFront !== front || i === samples - 1) && start >= 0) {
+ ribbon(points, start, isFront === front ? i + 1 : i, overMark);
+ start = -1;
+ }
+ }
+ if ((points[0][2] >= 0) === front) glowDot(points[0], overMark ? palette.glow : palette.hot, depthAlpha(points[0][2]));
+ }
+
+ function draw(time) {
+ clear();
+ const sparks = [0, 1, 2].map((orbit) => Array.from({ length: samples + 1 }, (_, sample) => {
+ const t = time - sample * 0.014;
+ const angle = (orbit + 1) * 1.7 + tau * t * (orbit % 2 ? -1 : 1);
+ const inclination = 1.2 + 0.14 * Math.sin(t * 0.9 + orbit);
+ const plane = orbit * Math.PI / 3 + 0.35 + 0.32 * t;
+ const x = radius * Math.cos(angle), y = radius * Math.sin(angle);
+ const tiltedY = y * Math.cos(inclination);
+ return [size / 2 + x * Math.cos(plane) - tiltedY * Math.sin(plane),
+ size / 2 + x * Math.sin(plane) + tiltedY * Math.cos(plane), Math.sin(angle) * Math.sin(inclination)];
+ }));
+ const blend = palette.dark ? 'lighter' : 'source-over';
+ ctx.globalCompositeOperation = blend;
+ sparks.forEach((points) => drawSpark(points, false));
+ drawMark();
+ ctx.globalCompositeOperation = blend;
+ sparks.forEach((points) => drawSpark(points, true));
+ if (palette.dark) {
+ ctx.globalCompositeOperation = 'source-over';
+ ctx.save();
+ markTransform();
+ ctx.clip(mark, 'evenodd');
+ ctx.setTransform(scale, 0, 0, scale, 0, 0);
+ sparks.forEach((points) => drawSpark(points, true, true));
+ ctx.restore();
+ }
+ ctx.globalCompositeOperation = 'source-over';
+ }
+
+ function settle() {
+ cancelAnimationFrame(frame);
+ frame = 0;
+ restyle();
+ clear();
+ drawMark();
+ }
+
+ function tick(now) {
+ if (now - startedAt >= duration || shortcut.hidden || document.visibilityState === 'hidden' || motion.matches) {
+ settle();
+ return;
+ }
+ draw((now - startedAt) / 1000);
+ frame = requestAnimationFrame(tick);
+ }
+
+ const watch = new MutationObserver(() => { if (shortcut.hidden) settle(); });
+ watch.observe(shortcut, { attributes: true, attributeFilter: ['hidden'] });
+ document.addEventListener('visibilitychange', settle);
+ motion.addEventListener('change', settle);
+ theme.addEventListener('change', settle);
+ settle();
+ return {
+ play() {
+ settle();
+ if (motion.matches || document.visibilityState === 'hidden') return;
+ startedAt = performance.now();
+ frame = requestAnimationFrame(tick);
+ },
+ destroy() {
+ cancelAnimationFrame(frame);
+ watch.disconnect();
+ document.removeEventListener('visibilitychange', settle);
+ motion.removeEventListener('change', settle);
+ theme.removeEventListener('change', settle);
+ },
+ };
+ }
+
function isTextField(element) {
return element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement;
}
@@ -326,7 +503,8 @@
color:inherit; font-weight:550; cursor:pointer;
}
.bar-item:hover { background:var(--hover); }
- .bar-item[data-more] { flex:none; }
+ .bar-item[data-more] { display:flex; align-items:center; gap:5px; flex:none; }
+ .more-brain { display:block; flex:none; width:22px; height:22px; pointer-events:none; }
.bar-label { display:block; overflow:hidden; text-overflow:ellipsis; }
/* On a narrow viewport the bar tightens, then shortens the other labels, so More stays on screen. */
@media (max-width:420px) { .bar-item { padding:8px 8px; } }
@@ -497,7 +675,7 @@
<span class="bar-sep" aria-hidden="true"></span>
<button class="bar-item" type="button" data-inline="proofread"><span class="bar-label">Proofread</span></button>
<span class="bar-sep" aria-hidden="true"></span>
- <button class="bar-item" type="button" data-more aria-haspopup="dialog" aria-expanded="false"><span class="bar-label">More…</span></button>
+ <button class="bar-item" type="button" data-more aria-haspopup="dialog" aria-expanded="false"><canvas class="more-brain" width="44" height="44" aria-hidden="true"></canvas><span class="bar-label">More…</span></button>
</div>
<div class="popup" role="dialog" aria-label="Ask WebBrain about this" hidden>
<div class="main-view">
@@ -651,6 +829,7 @@
setTimeout(() => { interacting = false; }, 0);
}, true);
(document.documentElement || document.body).appendChild(host);
+ moreBrain = mountMoreBrain(moreButton.querySelector('.more-brain'));
}
function getVisibleSelectionBottom() {
@@ -784,6 +963,7 @@
sendButton.disabled = true;
shortcut.hidden = false;
positionShortcut();
+ moreBrain?.play();
}
async function openPopup() {
@@ -1152,6 +1332,8 @@
hideToast();
cancelInline();
cardRequestId += 1;
+ moreBrain?.destroy();
+ moreBrain = null;
host?.remove();
host = shadow = highlightLayer = shortcut = moreButton = popup = question = includePageContext = sendButton = toast = null;
card = cardParts = cardState = cardOpener = null;
diff --git a/src/firefox/src/content/selection-shortcut.js b/src/firefox/src/content/selection-shortcut.js
index e8fb5c98b..d5dac3f9b 100644
--- a/src/firefox/src/content/selection-shortcut.js
+++ b/src/firefox/src/content/selection-shortcut.js
@@ -83,6 +83,7 @@
let highlightLayer = null;
let shortcut = null;
let moreButton = null;
+ let moreBrain = null;
let popup = null;
let question = null;
let includePageContext = null;
@@ -107,6 +108,182 @@
return Math.max(min, Math.min(max, value));
}
+ // The small Nucleus mark and orbit renderer from assets/loader-candidates/.
+ // Play two orbits on reveal, then leave only the monochrome mark.
+ function mountMoreBrain(canvas) {
+ let ctx = null;
+ try { ctx = canvas?.getContext('2d'); } catch { /* More remains usable without canvas. */ }
+ if (!ctx || typeof Path2D !== 'function') return { play() {}, destroy() {} };
+ const mark = new Path2D('M46.6 93.2C46 92.7 45.5 91.5 45 89.6C44.6 87.9 44 86 43.7 85.2C42.8 83.1 42.9 82.9 44.7 81.9C45.6 81.4 47.2 80.2 48.2 79.3L50 77.6L51.5 78.9C52.2 79.7 53.7 80.8 54.7 81.5C57.1 83.1 57.1 83.3 56.2 85.6C55.8 86.7 55.2 88.6 55 89.9C54.3 93.2 53.5 93.8 50 93.8C48.1 93.8 47.2 93.7 46.6 93.2ZM26.6 81.8C24.1 80.9 21.6 79.3 20.6 77.8C19.2 75.8 19.3 75.5 21.5 75.2C23.4 75 26.9 73.1 26.9 72.3C26.9 72 26.5 71.9 25.7 72.1C19.4 73.3 16 72 14.6 67.9C14.4 67.1 14 66.5 13.8 66.5C12.5 66.5 13.1 69.9 14.8 72.1C16.3 74 16.1 74.1 13.2 73.3C3.5 70.4 5.5 55.2 15.3 57.3C17.9 57.8 18 57.1 15.7 55.9C11.7 53.8 5.8 56.7 4.5 61.4C4 63.3 3.8 63.4 3 62.4C-0.1 59 -0 50.7 3.1 47.9C3.7 47.3 3.8 47.4 4.4 48.3C5.3 49.7 5.9 49.5 5.6 47.7C5.3 46 5.9 43.5 6.9 42.2C7.8 41 7.9 40.8 7.2 40.8C6.7 40.8 5.1 42.3 3.4 44.5C1.6 46.9 1.6 40.5 3.4 37C4.5 35 5.3 34.1 7.1 32.9C8.4 32 8.5 31.8 8.6 29.9C8.7 27.1 10.4 23.9 12.6 21.9C17.9 17.2 29 17.5 28.9 22.2C28.9 25.5 28.5 26.4 26.8 26.7C24 27.2 22.9 28.5 25.3 28.5C28.7 28.5 31.2 31.5 31.2 35.6C31.2 39 31.7 40.2 34.2 42.9C37.2 46.1 38.1 49 36.7 52.2C36.2 53.5 36.2 53.6 36.8 54.3C37.8 55.4 37.8 55.4 41.5 48.4C46.3 39.5 47.7 38.2 51.5 39.2C53.7 39.8 54.6 40.9 58.3 48C62 55 62.2 55.3 63.2 54.3C63.8 53.7 63.8 53.5 63.3 52.2C61.9 49 62.7 46.3 66 42.7C67.3 41.2 68.5 40 68.5 39.9C68.5 39.9 68.7 38.1 68.8 36.1C69.2 31 70.7 29 74.4 28.6C75.4 28.4 76.2 28.2 76.2 27.9C76.2 27.4 73.7 26.5 72.4 26.5C71.8 26.5 71.5 26.3 71.5 25.6C71.5 25.1 71.4 24.2 71.1 23.6C70.4 21.4 73 18.5 75.7 18.5C76.9 18.5 77.1 17.7 76.1 17.4C74.8 16.9 72 17.6 70.6 18.6L69.3 19.6L67.6 17.9C65.8 16.3 62.9 14.7 62.4 15.1C62.3 15.2 63.2 16.3 64.4 17.4C68.3 20.9 70.1 26.3 68.3 29L67.6 30.1L66.7 29.2C65.4 28 65 28.6 65.8 30.3C66.4 31.5 66.5 32.2 66.2 35.2C65.9 39.4 65.3 40.5 62.8 41.6C61.6 42.1 61.2 42.5 61.3 42.9C61.4 43.3 61.3 44 60.9 44.7L60.3 45.9L58.8 43C57 39.7 55.4 37.9 53.4 36.9C51.8 36.1 51.5 35.6 51.5 33.1C51.6 30.9 52.3 29.9 54.7 28.9C57 27.9 56.8 27.1 54.5 27.4C53.6 27.5 52.6 27.7 52.2 27.9C51.7 28.1 51.6 27.8 51.3 26C50.8 21.8 51.6 20 54.5 19C57.1 18.1 56.3 17.1 53.5 17.7C51.3 18.2 51.4 18.3 51.4 13.9C51.4 8.8 51.6 8.3 53.6 7.2C57.4 5.2 64.6 6.5 67.2 9.8C68.2 11.1 68.3 11.2 71 11.2C75.5 11.2 78.7 13.2 80.4 17C81 18.5 81.4 18.9 82.5 19.2C87 20.4 90.5 24.4 91.4 29C91.6 30.1 91.5 30.5 91 30.9C90.4 31.4 90.5 31.5 92.4 32.6C94.5 33.8 96.2 35.7 97.2 38.2C97.9 39.7 98.2 43.9 97.8 44.5C97.4 45.2 96.3 44.8 96 43.9C95.7 42.9 93.1 40.6 92.8 40.9C92.7 41.1 92.7 41.5 93 41.8C94 43.2 94.4 44.5 94.5 46.7C94.5 48 94.6 49.1 94.6 49.2C94.6 49.3 95.1 48.9 95.6 48.3C96.5 47.2 96.5 47.1 97.1 47.9C99.5 50.9 100.1 56.1 98.5 59.9C97.4 62.4 96.3 63.5 95.9 62.5C94.9 59.1 93.4 57.3 91 56.1C89 55 85.9 55 84.2 56C82.8 56.8 82.6 57.6 83.8 57.4C89.5 56.3 93.1 59 93.1 64.5C93.1 68.9 90.9 72.1 86.9 73.3C83.9 74.1 83.6 74 84.8 72.6C86.1 71.1 86.9 69.2 86.9 67.9C86.9 66.4 86.2 66.4 85.6 67.8C83.8 72.1 80.4 73.4 74.3 72.1C73.6 71.9 73.1 72 73.1 72.2C73.1 73 76.7 75 78.5 75.2C80.6 75.5 80.8 75.9 79.5 77.7C74.1 85.7 54.2 82.4 51.4 73C51 71.9 50.8 70.5 50.8 70C50.8 67.3 49.4 68.3 49.1 71.2C48.4 77.4 41.7 81.7 32.1 82.1C29.5 82.3 27.8 82.1 26.6 81.8ZM34.5 78.6C36 78 37.7 76.7 37.7 76.1C37.7 75.5 36.2 75.8 34 76.9C32.8 77.6 31.4 78.1 30.8 78.1C29.7 78.1 29 78.5 29.5 79C30 79.4 33.1 79.2 34.5 78.6ZM70.5 78.7C70.5 78.4 69.7 78.1 68.9 78C68 77.9 66.5 77.3 65.4 76.7C63.2 75.4 61.7 75.6 62.9 77C64.5 78.8 70.8 80.1 70.5 78.7ZM40.9 69.4C42.2 69.1 43.8 68.8 44.4 68.8C45.3 68.7 45.6 68.5 45.5 67.9C45.4 67.4 45.9 66.1 46.6 64.9C47.3 63.8 48.3 61.9 48.8 60.8C50.1 58.3 50 58.3 51.6 61.6C52.3 63.1 53.3 65 53.9 65.8C54.6 66.7 54.8 67.4 54.6 67.7C54.1 68.5 54.5 68.8 56.2 68.8C57 68.8 58.1 69 58.4 69.2C59.7 69.9 63.2 70.1 65 69.6C66.4 69.3 67.3 68.6 69.6 66.1C72.6 63 73.8 62.3 76.4 62.3C78.2 62.3 78 61.6 75.9 60.7C74.2 60 74.2 59.9 74.5 58.5C75.4 53.5 77.8 51.1 82.7 50C85 49.6 87.9 47.9 88.3 47C88.6 46.1 88.2 46 86.9 46.8C85.7 47.4 79.2 48.6 78.9 48.2C78.2 47.5 81.7 40.9 84 38.7C87.6 35.3 87.9 31.3 84.8 28.5C83.7 27.4 83.2 27.6 83.9 28.9C85.3 31.6 84.1 35.5 81.2 37.2C79.4 38.4 79.3 38.5 76.7 44.7C68.2 65.1 67.1 66.9 62.1 66.9C58.2 66.9 56.9 65.6 53 58C51.6 55.1 50.2 52.7 50 52.7C49.8 52.7 48.3 55.5 46.5 58.8C42.9 65.9 42.2 66.6 38.3 66.8C33.4 67.1 32.2 65.5 25.5 50L20.6 38.4L18.6 37.1C15.9 35.3 15.1 32.4 16.3 28.6C16.8 27.2 15.9 27.5 14.6 29.3C12.2 32.6 12.9 36.2 16.4 39.1C18.2 40.6 21.8 47.6 21.1 48.2C20.8 48.5 14.3 47.4 13.2 46.8C10.7 45.5 11.6 47.3 14.2 49C14.8 49.3 16.2 49.8 17.3 50C21.5 50.9 23.3 52.3 24.8 56.1C26.1 59.2 26.1 60.2 24.7 60.6C21.7 61.3 21.9 62.1 25.2 62.5C27 62.7 27.3 63 29.8 65.6C34 69.9 36 70.6 40.9 69.4ZM39.1 44.8C38.8 44.1 38.6 43.3 38.6 43C38.6 42.6 38 42 36.9 41.5C34.5 40.2 33.9 39 33.8 34.8C33.7 32.2 33.8 31 34.3 30.1C35.1 28.6 34.7 28.2 33.3 29.2L32.3 30L31.7 29C29.9 26.3 31.8 20.8 35.6 17.4C37 16.2 37.6 15.4 37.3 15.2C36.8 14.9 32.9 17.2 31.7 18.6L30.8 19.7L29.5 18.7C27.8 17.5 26.1 16.9 22.8 16.7C19.7 16.4 19.6 16.3 21 14.6C22.9 12.4 25.1 11.4 28.7 11.2C31.8 11.1 31.9 11 32.9 9.8C36.1 5.5 46.9 5 48.5 9.1C48.9 10.3 49 17.6 48.5 17.8C48.4 17.9 47.6 17.9 46.7 17.7C45.8 17.5 45 17.5 44.5 17.7C43.6 18.2 43.9 18.7 45.3 19C48.2 19.5 49.5 22.6 48.7 26.7C48.5 28 48.3 28.1 47.6 27.8C46.3 27.4 44.1 27.4 44 27.9C43.9 28.1 44.7 28.7 45.8 29.1C49.1 30.5 50 35 47.2 36.5C44.9 37.7 43.1 39.7 41.4 42.8L39.7 45.9L39.1 44.8Z');
+ const size = 22;
+ const tau = Math.PI * 2;
+ const duration = 2000;
+ const radius = size * 0.44;
+ const markPx = size * 0.62;
+ const samples = 10;
+ const motion = window.matchMedia('(prefers-reduced-motion: reduce)');
+ const theme = window.matchMedia('(prefers-color-scheme: dark)');
+ const mono = (value) => [value, value, value];
+ const rgba = (color, alpha) => `rgba(${color.join(',')},${clamp(alpha, 0, 1)})`;
+ let scale = 1;
+ let palette;
+ let frame = 0;
+ let startedAt = 0;
+
+ function restyle() {
+ scale = clamp(window.devicePixelRatio || 1, 1, 4);
+ canvas.width = canvas.height = Math.round(size * scale);
+ const rgb = getComputedStyle(moreButton).color.match(/[\d.]+/g)?.slice(0, 3).map(Number) || [23, 23, 23];
+ const ink = Math.round(rgb[0] * 0.2126 + rgb[1] * 0.7152 + rgb[2] * 0.0722);
+ const dark = ink > 128;
+ palette = { dark, ink: mono(ink), glow: mono(dark ? ink * 0.8 : ink + 60), hot: mono(dark ? 255 : ink) };
+ }
+
+ function markTransform() {
+ ctx.translate((size - markPx) / 2, (size - markPx) / 2);
+ ctx.scale(markPx / 100, markPx / 100);
+ }
+
+ function drawMark() {
+ ctx.globalCompositeOperation = 'source-over';
+ ctx.save();
+ markTransform();
+ ctx.fillStyle = rgba(palette.ink, 1);
+ ctx.fill(mark, 'evenodd');
+ ctx.restore();
+ }
+
+ function clear() {
+ ctx.setTransform(scale, 0, 0, scale, 0, 0);
+ ctx.clearRect(0, 0, size, size);
+ }
+
+ function glowDot(point, color, alpha) {
+ const r = 2.1 * (palette.dark ? 1.3 : 1.05);
+ const gradient = ctx.createRadialGradient(point[0], point[1], 0, point[0], point[1], r);
+ gradient.addColorStop(0, rgba(color, alpha));
+ gradient.addColorStop(0.25, rgba(palette.glow, alpha * 0.7));
+ gradient.addColorStop(1, rgba(palette.glow, 0));
+ ctx.fillStyle = gradient;
+ ctx.beginPath();
+ ctx.arc(point[0], point[1], r, 0, tau);
+ ctx.fill();
+ }
+
+ const depthAlpha = (z) => z < 0 ? 0.3 + 0.42 * (1 + z) : 0.86 + 0.14 * z;
+ const depthWidth = (z) => z < 0 ? 0.76 + 0.16 * (1 + z) : 1 + 0.22 * z;
+
+ // Tapered ribbons, with the same depth split as the original Nucleus.
+ function ribbon(points, start, end, overMark) {
+ if (end <= start) return;
+ const left = [], right = [];
+ for (let i = start; i <= end; i++) {
+ const before = points[Math.max(0, i - 1)], after = points[Math.min(samples, i + 1)];
+ const length = Math.hypot(after[0] - before[0], after[1] - before[1]) || 1;
+ const width = (1.5 * Math.pow(1 - i / samples, 0.8) + 0.3) * depthWidth(points[i][2]) / 2;
+ const nx = -(after[1] - before[1]) / length * width;
+ const ny = (after[0] - before[0]) / length * width;
+ left.push([points[i][0] + nx, points[i][1] + ny]);
+ right.push([points[i][0] - nx, points[i][1] - ny]);
+ }
+ ctx.beginPath();
+ left.forEach(([x, y], i) => i ? ctx.lineTo(x, y) : ctx.moveTo(x, y));
+ for (let i = right.length - 1; i >= 0; i--) ctx.lineTo(...right[i]);
+ ctx.closePath();
+ const gradient = ctx.createLinearGradient(...points[start].slice(0, 2), ...points[end].slice(0, 2));
+ for (const offset of [0, 0.5, 1]) {
+ const i = Math.round(start + (end - start) * offset);
+ const u = i / samples;
+ const color = overMark ? palette.glow : palette.hot.map((value, k) => Math.round(value + (palette.glow[k] - value) * Math.min(1, u * 1.7)));
+ gradient.addColorStop(offset, rgba(color, Math.pow(1 - u, 1.5) * depthAlpha(points[i][2]) * 0.95));
+ }
+ ctx.fillStyle = gradient;
+ ctx.fill();
+ }
+
+ function drawSpark(points, front, overMark = false) {
+ let start = -1;
+ for (let i = 0; i < samples; i++) {
+ const isFront = (points[i][2] + points[i + 1][2]) / 2 >= 0;
+ if (isFront === front && start < 0) start = i;
+ if ((isFront !== front || i === samples - 1) && start >= 0) {
+ ribbon(points, start, isFront === front ? i + 1 : i, overMark);
+ start = -1;
+ }
+ }
+ if ((points[0][2] >= 0) === front) glowDot(points[0], overMark ? palette.glow : palette.hot, depthAlpha(points[0][2]));
+ }
+
+ function draw(time) {
+ clear();
+ const sparks = [0, 1, 2].map((orbit) => Array.from({ length: samples + 1 }, (_, sample) => {
+ const t = time - sample * 0.014;
+ const angle = (orbit + 1) * 1.7 + tau * t * (orbit % 2 ? -1 : 1);
+ const inclination = 1.2 + 0.14 * Math.sin(t * 0.9 + orbit);
+ const plane = orbit * Math.PI / 3 + 0.35 + 0.32 * t;
+ const x = radius * Math.cos(angle), y = radius * Math.sin(angle);
+ const tiltedY = y * Math.cos(inclination);
+ return [size / 2 + x * Math.cos(plane) - tiltedY * Math.sin(plane),
+ size / 2 + x * Math.sin(plane) + tiltedY * Math.cos(plane), Math.sin(angle) * Math.sin(inclination)];
+ }));
+ const blend = palette.dark ? 'lighter' : 'source-over';
+ ctx.globalCompositeOperation = blend;
+ sparks.forEach((points) => drawSpark(points, false));
+ drawMark();
+ ctx.globalCompositeOperation = blend;
+ sparks.forEach((points) => drawSpark(points, true));
+ if (palette.dark) {
+ ctx.globalCompositeOperation = 'source-over';
+ ctx.save();
+ markTransform();
+ ctx.clip(mark, 'evenodd');
+ ctx.setTransform(scale, 0, 0, scale, 0, 0);
+ sparks.forEach((points) => drawSpark(points, true, true));
+ ctx.restore();
+ }
+ ctx.globalCompositeOperation = 'source-over';
+ }
+
+ function settle() {
+ cancelAnimationFrame(frame);
+ frame = 0;
+ restyle();
+ clear();
+ drawMark();
+ }
+
+ function tick(now) {
+ if (now - startedAt >= duration || shortcut.hidden || document.visibilityState === 'hidden' || motion.matches) {
+ settle();
+ return;
+ }
+ draw((now - startedAt) / 1000);
+ frame = requestAnimationFrame(tick);
+ }
+
+ const watch = new MutationObserver(() => { if (shortcut.hidden) settle(); });
+ watch.observe(shortcut, { attributes: true, attributeFilter: ['hidden'] });
+ document.addEventListener('visibilitychange', settle);
+ motion.addEventListener('change', settle);
+ theme.addEventListener('change', settle);
+ settle();
+ return {
+ play() {
+ settle();
+ if (motion.matches || document.visibilityState === 'hidden') return;
+ startedAt = performance.now();
+ frame = requestAnimationFrame(tick);
+ },
+ destroy() {
+ cancelAnimationFrame(frame);
+ watch.disconnect();
+ document.removeEventListener('visibilitychange', settle);
+ motion.removeEventListener('change', settle);
+ theme.removeEventListener('change', settle);
+ },
+ };
+ }
+
function isTextField(element) {
return element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement;
}
@@ -326,7 +503,8 @@
color:inherit; font-weight:550; cursor:pointer;
}
.bar-item:hover { background:var(--hover); }
- .bar-item[data-more] { flex:none; }
+ .bar-item[data-more] { display:flex; align-items:center; gap:5px; flex:none; }
+ .more-brain { display:block; flex:none; width:22px; height:22px; pointer-events:none; }
.bar-label { display:block; overflow:hidden; text-overflow:ellipsis; }
/* On a narrow viewport the bar tightens, then shortens the other labels, so More stays on screen. */
@media (max-width:420px) { .bar-item { padding:8px 8px; } }
@@ -497,7 +675,7 @@
<span class="bar-sep" aria-hidden="true"></span>
<button class="bar-item" type="button" data-inline="proofread"><span class="bar-label">Proofread</span></button>
<span class="bar-sep" aria-hidden="true"></span>
- <button class="bar-item" type="button" data-more aria-haspopup="dialog" aria-expanded="false"><span class="bar-label">More…</span></button>
+ <button class="bar-item" type="button" data-more aria-haspopup="dialog" aria-expanded="false"><canvas class="more-brain" width="44" height="44" aria-hidden="true"></canvas><span class="bar-label">More…</span></button>
</div>
<div class="popup" role="dialog" aria-label="Ask WebBrain about this" hidden>
<div class="main-view">
@@ -651,6 +829,7 @@
setTimeout(() => { interacting = false; }, 0);
}, true);
(document.documentElement || document.body).appendChild(host);
+ moreBrain = mountMoreBrain(moreButton.querySelector('.more-brain'));
}
function getVisibleSelectionBottom() {
@@ -784,6 +963,7 @@
sendButton.disabled = true;
shortcut.hidden = false;
positionShortcut();
+ moreBrain?.play();
}
async function openPopup() {
@@ -1152,6 +1332,8 @@
hideToast();
cancelInline();
cardRequestId += 1;
+ moreBrain?.destroy();
+ moreBrain = null;
host?.remove();
host = shadow = highlightLayer = shortcut = moreButton = popup = question = includePageContext = sendButton = toast = null;
card = cardParts = cardState = cardOpener = null;