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

web-marker

v1.1.2

Published

a tool for add marker or highlight in webpage

Downloads

48

Readme

web-marker

介绍

  • 获取选中文本信息;
  • 主要用于在静态网页上做标记(高亮), 当然前提是网页上的内容不会发生变化, 一旦发生变化之前做的标记将会错乱;
  • 当然也可作为简单的文本选中工具;
  • 暂不支持跨多节点标记内容;
  • 支持移动端, 但因在移动端选中文字后系统会有默认的弹框操作, 所以得让小伙伴在webView里把这个系统功能禁用掉;
  • 可根据需求添加想要的操作按钮,具体使用方法参考: demo/index.html;
  • 样式可自定义, 写法参考: demo/web-marker.css;

效果演示

alt demo

查看DEMO

安装

npm i web-marker

使用

import WebMarker from 'web-marker'

let defaultMarkers = JSON.parse(localStorage.getItem('markers'))
// 创建实例, npm 安装使用的话 直接 new WebMarker({...})
const webMarker = new WebMarker({
  defaultMarkers: defaultMarkers, // 默认标记数据 (选填), 数据格式为 getAllMarkes 返回结果
  selectedClassName: '_temp_marker', // 选中后样式名 (必填)
  markedClassName: '_web_marker', // 标记样式名 (必填)
  focusMarkedClassName: '_focus_web_marker', // 选中已标记样式名 (必填)
  btnWrapperID: 'webMarkerBtn_Wrapper', // 弹框节点 ID (必填)
  disabledDom: ['BUTTON', 'H1', 'H2', 'IMG'], // 禁用此功能标签 (选填)
  btns: [{
    label: '标记',
    event: () => {
      webMarker.mark()
      // 如果需要保存在本地的话可自行处理, 如:
      // const markersJson = JSON.stringify(webMarker.getAllMarkes())
      // localStorage.setItem('markers', markersJson)
    }
  },{
    label: '百科', 
    event: () => {
      // 获取当前选中的文本内容
      const text = webMarker.getSelectedText()
      window.location.href = `https://baike.baidu.com/search/none?word=${text}`
    }
  },{
    label: '全部标记信息', 
    event: () => {
      const allText = webMarker.getAllMarkes()
      console.log(allText)
    }
  }, {
    label: '当前标记ID', 
    event: () => {
      const id = webMarker.getCurrentId()
      console.log(id)
    }
  },{
    label: '删除', 
    event: () => {
      webMarker.del()
    }
  }]
})