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

acfun-live-danmaku

v0.8.0

Published

acfun直播弹幕获取

Readme

acfun-live-danmaku

简介

acfun-live-danmaku 是一个用于获取 AcFun 直播弹幕的 JavaScript 库

  • 支持在浏览器环境和 NodeJS 环境下运行, 使用 NodeJS v22 LTS 开发

安装

npm i acfun-live-danmaku --save

使用方式

import { getAcClient } from "acfun-live-danmaku"

// 使用init(主播房间号)初始化客户端
AcClient("8500263").then(({ client }) => {
    // 启动websocket连接
    client.wsStart();
    client.addEventListener("EnterRoomAck", () => {
        console.log("Enter room success!");
    });
    client.addEventListener("RecentComment", ({ data }) => {
        // 获得建立连接当前的弹幕列表
        console.log(data);
    });
    client.addEventListener("Comment", ({ data }) => {
        // 收到的弹幕
        console.log(data);
    });
});

收到的弹幕返回如下

{
    content: '晚安',
    sendTimeMs: Long {
        low: -1921110048,
        high: 372,
        unsigned: false
    },
    userInfo: ZtLiveUserInfo {
        avatar: [
            [ImageCdnNode]
        ],
        userId: Long {
            low: 147764,
            high: 0,
            unsigned: false
        },
        nickname: 'NNK',
        badge: '{"medalInfo":{"uperId":100001,"userId":100001,"clubName":"蓝钻","level":100}}',
        userIdentity: ZtLiveUserIdentity {}
    }
}

事件列表

| 事件 | 消息 | payload 类型 | | ---------------- | ------------------ | ---------------------------------- | | open | 已连接到服务器 | | | close | 连接已关闭 | | | message | 接收到消息 | | | error | 连接发生错误 | | | | | | | EnterRoomAck | 已连接到直播间 | | | | | | | ActionSignal | 行为事件 | | | Comment | 弹幕 | CommonActionSignalComment | | Like | 点赞 | CommonActionSignalLike | | Gift | 发送礼物 | CommonActionSignalGift | | UserFollowAuthor | 关注主播 | CommonActionSignalUserFollowAuthor | | UserEnterRoom | 用户进入直播间 | CommonActionSignalUserEnterRoom | | JoinClub | 用户加入主播守护团 | AcfunActionSignalJoinClub | | | | | | StateSignal | 状态事件 | | | DisplayInfo | 当前直播间数据状态 | CommonStateSignalDisplayInfo | | RecentComment | 当前弹幕列表 | CommonStateSignalRecentComment | | TopUsers | 前几名用户的数据 | CommonStateSignalTopUsers |