Skip to content

iocium/domhash

Repository files navigation

@iocium/domhash

Structure-aware and layout-aware perceptual hashing for HTML/DOM trees. Robust similarity detection, diffs, and resilience scoring with flexible CLI and API.

npm version License: MIT CI

Table of Contents

Features

  • Structural and visual similarity detection for DOM trees
  • Layout-aware canonicalization with run-length encoding of layout shapes
  • Run-length encoding (RLE) compression for shape vectors
  • Hidden element support: prefixes and collapsing of consecutive hidden tags
  • Flexible attribute handling: include/exclude data-, aria-, and custom attributes
  • Resilience scoring to detect brittle or obfuscated DOMs with detailed penalties
  • Support for perceptual hash algorithms: sha256, murmur3, blake3, simhash, minhash
  • Detailed structural diffs in Markdown/HTML output
  • Rich CLI and programmatic API
  • 100% test coverage and CI integration

Installation

npm install @iocium/domhash

CLI Usage

Usage:

npx domhash <command> [options]

Commands:

hash [options] Compute hash of a DOM input compare [options] Compare two DOM inputs (structural & shape) diff [options] Show structural differences between two inputs shape [options] Output compressed shape vector of a DOM input layout [options] Output layout shape vector and layout hash resilience [options] Output resilience score and breakdown

For detailed help on a specific command:

npx domhash <command> --help

Examples

// Compare two pages and generate a Markdown report:

npx domhash compare page1.html page2.html --diff --output markdown > report.md

License

MIT License — see LICENSE for details.


Made with 💙 by iocium

About

Structure-aware and layout-aware perceptual hashing for HTML and DOM content.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published