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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@szjy/spread-tool

v1.0.3

Published

一个用于处理命令行参数的工具

Readme

spread-tool

一个简单易用的命令行工具,用于自动化浏览器登录和页面访问。支持 token 方式登录。

安装

npm install -g @szjy/spread-tool

使用方法

基本命令格式:

spread-tool -l <目标地址> -t <登录令牌>

参数说明

  • -l, --targetUrl: 目标页面地址(必填,格式:http://hostname:port/projectId/xxx/xxx)
  • -t, --token: 登录令牌(必填)
  • -k, --keep: 保持浏览器窗口打开(可选,默认自动关闭)

使用示例

# 示例 1:访问页面后自动关闭浏览器
spread-tool -l  "http://172.17.114.123:30012/KZGSBIM/project/workflow/auto-tool/excel-to-pdf?auto=true&keys=791701453658914816,792047977693708288" -t your-token-here

# 示例 2:访问页面后保持浏览器窗口打开
spread-tool -l  "http://172.17.114.123:30012/KZGSBIM/project/workflow/auto-tool/excel-to-pdf?auto=true&keys=791701453658914816,792047977693708288" -t your-token-here -k

功能说明

  1. 自动解析目标地址,提取项目标识符
  2. 自动构造登录地址并使用 token 进行登录
  3. 等待登录完成后自动跳转到目标页面
  4. 智能等待页面处理完成后自动关闭
  5. 全程自动化操作,无需人工干预

工作流程

  1. 从目标URL中提取项目标识符和基础URL
    • 例如:从 http://example.com/aaa/123/dashboard
    • 提取项目标识符 aaa
    • 构造基础URL http://example.com/aaa
  2. 构造登录URL:{baseUrl}/login?token={token}
  3. 自动访问登录页面并等待登录完成(3秒)
  4. 自动跳转到目标页面
  5. 等待页面处理完成
    • 监听页面中 id 为 webdriverCloseTag 的元素
    • 当元素内容为 true 时,自动关闭浏览器
    • 如果 1 小时内未收到关闭信号,将超时退出
    • 每 20 秒检查一次关闭信号

URL 格式说明

目标URL需要符合以下格式:

  • http(s)://hostname[:port]/projectId/...
  • 其中 projectId 是项目标识符,可以是任意有效的路径名
  • 项目标识符后面必须至少包含一个路径段

开发说明

本工具使用了以下主要依赖:

  • commander: 用于解析命令行参数
  • chalk: 用于美化命令行输出
  • webdriverio: 用于浏览器自动化操作

自动关闭机制

工具会监听页面中的特定元素来决定何时关闭浏览器:

  1. 页面中需要包含一个 id 为 webdriverCloseTag 的元素
  2. 当页面处理完成时,将该元素的内容设置为 true
  3. 工具检测到信号后会自动关闭浏览器
  4. 如果使用 -k 参数,则忽略自动关闭机制

示例页面代码:

<div id="webdriverCloseTag">false</div>

<!-- 在处理完成后 -->
<script>
  document.getElementById('webdriverCloseTag').innerHTML = 'true';
</script>

注意事项

  • URL 必须包含有效的项目标识符
  • 登录令牌必须是有效的
  • 需要本地安装 Chrome 浏览器
  • 建议在安全的环境中使用此工具
  • 如果目标URL包含特殊字符(如逗号、空格等),请使用引号将整个URL包裹
  • 或者考虑对URL中的特殊字符进行URL编码
  • 目标页面需要正确实现关闭信号机制,否则工具将在 1 小时后超时退出

许可证

ISC