Download source/scripts/phone-cleanup.mjs from WilburDev/earshelf: direct link, hf CLI and curl.
- Browser
- Download file 720 Bytes
-
https://huggingface.co/spaces/WilburDev/earshelf/resolve/main/source/scripts/phone-cleanup.mjs
- Command line
-
hf download hf://spaces/WilburDev/earshelf/source/scripts/phone-cleanup.mjs
-
curl -L -o phone-cleanup.mjs https://huggingface.co/spaces/WilburDev/earshelf/resolve/main/source/scripts/phone-cleanup.mjs
720 Bytes
| // Removes all EarShelf test data from the phone's Chrome and closes only the tab this session opened. | |
| import { chromium } from '@playwright/test'; | |
| const b = await chromium.connectOverCDP('http://localhost:9333'); | |
| const ctx = b.contexts()[0]; | |
| const p = ctx.pages().find((x) => x.url().startsWith('http://localhost:4175')); | |
| if (p) { | |
| await p.evaluate(async () => { for (const r of await navigator.serviceWorker.getRegistrations()) await r.unregister(); }); | |
| await (await ctx.newCDPSession(p)).send('Storage.clearDataForOrigin', { origin: 'http://localhost:4175', storageTypes: 'all' }); | |
| await p.close(); | |
| } | |
| console.log('remaining tabs:', ctx.pages().map((x) => x.url().slice(0, 60))); | |
| await b.close().catch(() => {}); | |