npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dapplayright

v1.0.0

Published

Playwright automation helpers for DApps including MetaMask wallet management and social media token injection

Readme

dapplayright

Playwright automation helpers for DApps including MetaMask wallet management and social media token injection.

Features

  • 🔐 MetaMask Wallet Automation: Automatically import wallets, handle connection and signing popups
  • 🐦 X (Twitter) Token Injection: Automatically login to X.com using auth tokens
  • 💬 Discord Token Injection: Automatically login to Discord using auth tokens
  • 🎭 Playwright Integration: Built on top of Playwright for reliable browser automation

Installation

npm install dapplayright
# or
yarn add dapplayright
# or
pnpm add dapplayright

Requirements

  • Node.js 18+
  • Playwright browsers installed (npx playwright install)

Usage

MetaMask Wallet Management

Import MetaMask Wallet

import { chromium } from '@playwright/test';
import { MetaMaskHelper } from 'dapplayright';

const browser = await chromium.launch({
  headless: false,
  args: [
    `--disable-extensions-except=/path/to/metamask-extension`,
    `--load-extension=/path/to/metamask-extension`
  ]
});

const context = await browser.newContext();
const seedPhrase = 'word1 word2 ... word12';
const password = 'your-password';

// Import wallet
const metamaskPage = await MetaMaskHelper.importWallet(
  context,
  seedPhrase,
  password
);

Handle MetaMask Connection Popup

// After triggering a connection request on your DApp
const connected = await MetaMaskHelper.approveConnect(context);

Handle MetaMask Signing Popup

// After triggering a signing request on your DApp
const signed = await MetaMaskHelper.approveSign(context);

Handle Both Connection and Signing

// Automatically handle both connection and signing popups
const { connected, signed } = await MetaMaskHelper.approveConnectAndSign(context);

X (Twitter) Token Injection

import { chromium } from '@playwright/test';
import { injectXToken } from 'dapplayright';

const browser = await chromium.launch({ headless: false });
const context = await browser.newContext();
const page = await context.newPage();

// Inject X token and auto-login
await injectXToken(page, 'your-x-auth-token');

Discord Token Injection

import { chromium } from '@playwright/test';
import { injectDiscordToken } from 'dapplayright';

const browser = await chromium.launch({ headless: false });
const context = await browser.newContext();
const page = await context.newPage();

// Inject Discord token and auto-login
await injectDiscordToken(page, 'your-discord-token');

API Reference

MetaMaskHelper

MetaMaskHelper.importWallet(context, seedPhrase, password)

Imports a MetaMask wallet using a seed phrase.

Parameters:

  • context: BrowserContext - Playwright browser context
  • seedPhrase: string - 12-word seed phrase
  • password: string - Wallet password

Returns: Promise<Page> - MetaMask extension page

MetaMaskHelper.approveConnect(context, timeout?)

Automatically approves a MetaMask connection popup.

Parameters:

  • context: BrowserContext - Playwright browser context
  • timeout?: number - Timeout in milliseconds (default: 15000)

Returns: Promise<boolean> - Whether connection was approved

MetaMaskHelper.approveSign(context, timeout?)

Automatically approves a MetaMask signing popup.

Parameters:

  • context: BrowserContext - Playwright browser context
  • timeout?: number - Timeout in milliseconds (default: 15000)

Returns: Promise<boolean> - Whether signing was approved

MetaMaskHelper.approveConnectAndSign(context, connectTimeout?, signTimeout?)

Automatically handles both connection and signing popups.

Parameters:

  • context: BrowserContext - Playwright browser context
  • connectTimeout?: number - Connection timeout in milliseconds (default: 15000)
  • signTimeout?: number - Signing timeout in milliseconds (default: 15000)

Returns: Promise<{ connected: boolean; signed: boolean }>

MetaMaskHelper.waitForExtension(context, timeout?)

Waits for MetaMask extension to load.

Parameters:

  • context: BrowserContext - Playwright browser context
  • timeout?: number - Timeout in milliseconds (default: 10000)

Returns: Promise<boolean> - Whether extension was detected

MetaMaskHelper.getMetaMaskPage(context, targetUrl?)

Gets or creates a MetaMask extension page.

Parameters:

  • context: BrowserContext - Playwright browser context
  • targetUrl?: string - Optional target URL within the extension

Returns: Promise<Page> - MetaMask extension page

MetaMaskConfig

Configuration constants for MetaMask:

  • EXTENSION_ID: string - MetaMask Chrome extension ID
  • DEFAULT_TIMEOUT: number - Default timeout in milliseconds
  • SEED_PHRASE_WORDS: number - Expected number of words in seed phrase (12)

Token Injection Functions

injectXToken(page, token)

Injects X (Twitter) auth token and automatically logs in.

Parameters:

  • page: Page - Playwright page object
  • token: string - X authentication token

Returns: Promise<void>

injectDiscordToken(page, token)

Injects Discord auth token and automatically logs in.

Parameters:

  • page: Page - Playwright page object
  • token: string - Discord authentication token

Returns: Promise<void>

Development

# Install dependencies
npm install

# Build
npm run build

# Watch mode
npm run dev

License

ISC

Disclaimer

This package is for automation and testing purposes. Use responsibly and in accordance with the terms of service of the platforms you're automating.