astro-claw 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/slack-setup.js +41 -0
package/package.json
CHANGED
package/slack-setup.js
CHANGED
|
@@ -117,6 +117,45 @@ export default async function selfDrivingSlackSetup() {
|
|
|
117
117
|
|
|
118
118
|
const page = (await browser.pages())[0] || await browser.newPage();
|
|
119
119
|
|
|
120
|
+
// ── Visual cue: inject banner on every page load ──
|
|
121
|
+
const BANNER_CSS = `
|
|
122
|
+
position: fixed; top: 0; left: 0; right: 0; z-index: 2147483647;
|
|
123
|
+
height: 36px; display: flex; align-items: center; justify-content: center; gap: 8px;
|
|
124
|
+
background: linear-gradient(135deg, #6C5CE7, #A855F7);
|
|
125
|
+
color: #fff; font: 600 13px/1 -apple-system, BlinkMacSystemFont, sans-serif;
|
|
126
|
+
box-shadow: 0 2px 8px rgba(108, 92, 231, 0.4);
|
|
127
|
+
letter-spacing: 0.3px;
|
|
128
|
+
`;
|
|
129
|
+
const BANNER_HTML = `
|
|
130
|
+
<div id="astro-claw-banner" style="${BANNER_CSS}">
|
|
131
|
+
<span style="font-size: 16px;">🤖</span>
|
|
132
|
+
<span>Astro Claw is driving this browser</span>
|
|
133
|
+
<span style="opacity: 0.6; font-weight: 400; font-size: 11px; margin-left: 4px;">— do not close</span>
|
|
134
|
+
</div>
|
|
135
|
+
`;
|
|
136
|
+
const BODY_PADDING = `
|
|
137
|
+
if (!document.body.dataset.astroClaw) {
|
|
138
|
+
document.body.style.paddingTop = (parseFloat(getComputedStyle(document.body).paddingTop) + 36) + 'px';
|
|
139
|
+
document.body.dataset.astroClaw = '1';
|
|
140
|
+
}
|
|
141
|
+
`;
|
|
142
|
+
const injectBanner = async (p) => {
|
|
143
|
+
try {
|
|
144
|
+
await p.evaluate((html, bodyJs) => {
|
|
145
|
+
if (!document.getElementById('astro-claw-banner')) {
|
|
146
|
+
document.body.insertAdjacentHTML('beforeend', html);
|
|
147
|
+
eval(bodyJs);
|
|
148
|
+
}
|
|
149
|
+
}, BANNER_HTML, BODY_PADDING);
|
|
150
|
+
} catch {}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// Inject banner after every navigation and periodically
|
|
154
|
+
page.on('load', () => injectBanner(page));
|
|
155
|
+
page.on('domcontentloaded', () => injectBanner(page));
|
|
156
|
+
page.on('framenavigated', () => setTimeout(() => injectBanner(page), 500));
|
|
157
|
+
const bannerInterval = setInterval(() => injectBanner(page), 2000);
|
|
158
|
+
|
|
120
159
|
// ── Step 1: Sign in to Slack (single tab, no interruptions) ──
|
|
121
160
|
console.log(` → Checking Slack login...`);
|
|
122
161
|
await page.goto("https://api.slack.com/apps", { waitUntil: "networkidle2", timeout: 30000 });
|
|
@@ -509,6 +548,7 @@ export default async function selfDrivingSlackSetup() {
|
|
|
509
548
|
}
|
|
510
549
|
|
|
511
550
|
// ── Clean up ──
|
|
551
|
+
clearInterval(bannerInterval);
|
|
512
552
|
await browser.close();
|
|
513
553
|
|
|
514
554
|
// Return whatever we captured
|
|
@@ -524,6 +564,7 @@ export default async function selfDrivingSlackSetup() {
|
|
|
524
564
|
return result;
|
|
525
565
|
} catch (err) {
|
|
526
566
|
console.log(` ${WARN} Browser automation error: ${err.message}`);
|
|
567
|
+
clearInterval(bannerInterval);
|
|
527
568
|
if (browser) await browser.close().catch(() => {});
|
|
528
569
|
return null;
|
|
529
570
|
}
|