matthewwong525/WongStack / .agents/plugins/browser
browser
VerifiedThe person's own browser, for errands.
| File | Kind | Size |
|---|---|---|
| README.md | markdown | 4.4 KB |
| SKILL.md | skill md | 3.6 KB |
| VERSION | other | 6 B |
| addon/background.js | script | 1.1 KB |
| addon/check.svg | other | 591 B |
| addon/manifest.json | config | 462 B |
| references/browser-proxy.md | markdown | 5.2 KB |
| references/browser-window.md | markdown | 6.4 KB |
| references/browsing.md | markdown | 18.6 KB |
| references/login-codes.md | markdown | 5.6 KB |
| references/password-manager.md | markdown | 8.3 KB |
| references/setup.md | markdown | 6.4 KB |
| scripts/addons.mjs | script | 26.3 KB |
| scripts/browse.mjs | script | 53.5 KB |
| scripts/browser-server.mjs | script | 50.8 KB |
| scripts/connect-browser.mjs | script | 17.3 KB |
| scripts/forwarder.mjs | script | 14.5 KB |
| scripts/launch-config.py | script | 7.4 KB |
| scripts/lib/cli.mjs | script | 1.2 KB |
| scripts/lib/env.mjs | script | 614 B |
| scripts/lib/primary-root.mjsexecutable | script | 1.9 KB |
| scripts/lib/profile.mjs | script | 1.4 KB |
| scripts/login-move.mjs | script | 4.0 KB |
| scripts/mask-keys.mjs | script | 2.9 KB |
| scripts/proxy-lines.mjs | script | 4.7 KB |
| scripts/refs.mjs | script | 5.4 KB |
scripts/login-move.mjs
View on GitHub// Moves the old camofox browser's site logins into the new profile once, Meta's sites left out: a Facebook login
// copied to another browser can lock the account, so Meta's sites are signed in fresh.
import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
/** Meta's sites, by registered domain; a cookie or an origin on any of them, or under one, is never copied. */
export const META_SITES = ['facebook.com', 'facebook.net', 'messenger.com', 'instagram.com', 'fbcdn.net', 'fbsbx.com', 'meta.com', 'threads.net', 'whatsapp.com', 'whatsapp.net'];
/** True when `host`, a cookie domain or an origin's host, is one of Meta's sites or under one. */
export function isMeta(host) {
const name = String(host ?? '').toLowerCase().replace(/^\./, '').replace(/\.$/, '');
return META_SITES.some(site => name === site || name.endsWith(`.${site}`));
}
/** The most the site storage step takes, so the whole start fits browse.mjs's wait; later origins are left out. */
export const MOVE_MS = 60_000;
const COOKIE_FIELDS = ['name', 'value', 'domain', 'path', 'expires', 'httpOnly', 'secure', 'sameSite'];
const hostOfOrigin = origin => { try { return new URL(origin).hostname; } catch { return ''; } };
/** Every old profile's cookies and site storage, Meta's left out. An unreadable file adds nothing. */
export function oldLogins(profilesDir) {
const cookies = [];
const origins = new Map();
let names = [];
try { names = readdirSync(profilesDir); } catch { /* no old browser */ }
for (const name of names) {
let state;
try { state = JSON.parse(readFileSync(join(profilesDir, name, 'storage-state.json'), 'utf8')); } catch { continue; }
for (const cookie of state.cookies ?? []) if (cookie?.domain && !isMeta(cookie.domain)) cookies.push(cookie);
for (const { origin, localStorage = [] } of state.origins ?? []) {
if (!origin || isMeta(hostOfOrigin(origin)) || !localStorage.length) continue;
origins.set(origin, [...(origins.get(origin) ?? []), ...localStorage]);
}
}
return { cookies, origins: [...origins].map(([origin, localStorage]) => ({ origin, localStorage })) };
}
/** Writes each origin's site storage from a blank page served in its place, so no request leaves the computer. */
async function writeStorage(context, origins, moveMs) {
if (!origins.length) return 0;
const end = Date.now() + moveMs;
let written = 0;
const page = await context.newPage();
try {
await page.route('**/*', route => route.fulfill({ status: 200, contentType: 'text/html', body: '<!doctype html>' }));
for (const { origin, localStorage } of origins) {
const left = end - Date.now();
if (left <= 0) break;
try {
await page.goto(origin, { waitUntil: 'domcontentloaded', timeout: Math.min(10_000, left) });
await page.evaluate(items => { for (const { name, value } of items) window.localStorage.setItem(name, value); }, localStorage);
written++;
} catch { /* one origin's storage is lost, not the move */ }
}
} finally {
await page.close().catch(() => {});
}
return written;
}
/** On the first start, with no `marker` file, copies the old logins into `context` and writes the marker; any later
* start copies nothing. Returns what was copied, or null when the marker was there. */
export async function moveLogins(context, { profilesDir, marker, moveMs = MOVE_MS }) {
if (existsSync(marker)) return null;
const { cookies, origins } = oldLogins(profilesDir);
const clean = cookies.map(cookie => Object.fromEntries(COOKIE_FIELDS.filter(field => cookie[field] !== undefined).map(field => [field, cookie[field]])));
// One cookie the browser refuses fails the whole call, so a refusal is retried one cookie at a time.
await context.addCookies(clean).catch(() => Promise.all(clean.map(cookie => context.addCookies([cookie]).catch(() => {}))));
const moved = { cookies: cookies.length, origins: await writeStorage(context, origins, moveMs) };
writeFileSync(marker, `${JSON.stringify({ moved: new Date().toISOString(), ...moved })}\n`, { mode: 0o600 });
return moved;
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |