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

aomei-tools

v1.1.1

Published

批量操作html文件

Readme

aomei-tools

aomei-tools 是一个批量处理 HTML 文件的工具,支持自定义 HTML 元素操作。通过该工具,您可以在指定目录中遍历 HTML 文件,进行删除元素、修改属性等操作,特别适合静态站点的优化和批量处理需求。

安装

使用 npm 安装 aomei-tools

npm install aomei-tools

快速开始

const { processHtmlFiles } = require('aomei-tools');

// 自定义处理逻辑
const processFunction = ($) => {
  // 示例: 删除 Google Fonts 链接、指定脚本等
  $('link[href*="fonts.googleapis.com"]').remove();
  $('link[href*="fonts.gstatic.com"]').remove();
  $('script[src="/resource/lib/lazysizes.js"]').remove();
  $('meta[name="identification"]').remove();
  $('script[async][defer]').removeAttr('defer');

  // 修改 img 标签的属性
  $("img").each((index, img) => {
    const $img = $(img);
    $img.removeClass("lazyload");
    const dataSrc = $img.attr("data-src");
    if (dataSrc) {
      $img.attr("src", dataSrc).removeAttr("data-src");
    }
    if (!$img.attr("loading")) {
      $img.attr("loading", "lazy");
    }
  });
};

// 配置处理参数
const folderPath = "E:\\Learningmaterials\\aomei-replace"; // 指定需要操作的文件夹路径
const excludedFolders = ["blog", ".git", ".idea"]; // 排除其中不需要替换的文件夹

// 调用处理函数
processHtmlFiles({ folderPath, excludedFolders, processFunction })
  .then(() => console.log("Processing completed"))
  .catch((err) => console.error("Error processing HTML files:", err));

参数说明

  • folderPath : 要处理的文件夹路径(支持绝对路径和相对路径)。
  • excludedFolders : 要排除的文件夹列表,使用数组格式,避免指定文件夹被处理。
  • processFunction : 自定义 HTML 处理逻辑,接收一个 cheerio 实例 $,通过操作 DOM 来进行处理。

功能说明

  • 批量 HTML 文件处理 :遍历文件夹中的 HTML 文件,根据 processFunction 定义的规则进行自定义操作。
  • 文件夹排除 :可通过 excludedFolders 参数排除不需要处理的文件夹。
  • 进度显示 :在文件处理过程中显示进度,帮助您了解处理的进展情况。

贡献

欢迎提交 issue 和 pull request 来贡献代码!