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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ssa_watermark

v1.4.1

Published

global watermark

Downloads

3

Readme

全局水印

效果

ssa_watermark是一个基于canvas生成前端水印js库,同时加入前端水印攻防逻辑,例如当有人恶意篡改水印,可以捕获行为发出警告并记录,同时恢复被篡改的水印.

安装 & 使用

  1. 安装
npm install ssa_watermark --save
  1. 使用
import watermark from 'ssa_watermark'

watermark({
    text: CookieTool.getItem('_ssa_username'),
    // 水印字体
    fontSize: 16,
    // 水印透明度
    opacity: 0.6,
    // 水印颜色
    color: '#e1e1e1',
    // 水印图片大小控制
    width = 150,
    height = 150,
    // 修改水印回调
    onChange: () => {
        this.$Message.warning('请勿修改水印,你的操作已被记录');
    },
    ignoreAttr: [],
    // 图片生成方式 canvas/svg 建议svg
    generateMethod: 'canvas',
});

Options

  1. text: 水印文案
  2. fontSize:字体大小
  3. opacity:水印透明度
  4. color:水印颜色
  5. width:生成水印图片宽
  6. height: 生成水印图片高
  7. onChange:水印节点被修改触发回调
  8. ignoreAttr:  (非必填,默认无忽略,全部检测,v1.3.0新增) 节点的这些属性被修改时 忽略检测 
  9. generateMethod: 默认canvas,可选canvas或者svg

FAQ

1、为什么水印有重影?

多半是因为多次调用了 Watermark();想办法保证只调用一次。

跟新

Feature v1.1.0

  1. 新增 containerDom 配置,用于配置水印DOM渲染父节点,注意:父节点非body,水印的position属性为absolute
  2. 新增 rotateDegree 配置,用于调整水印旋转角度,默认值 -15

Feature v1.2.1

  1. 新增zIndex配置,用于控制水印节点z-index属性, 默认值 9999
  2. 新增水印销毁函数:在调用watermark之后返回一个对象,挂载destroy函数。 ​

Feature v1.3.0

  1. 新增过滤属性的配置,用于忽略某些难以避免的属性修改

watermark({

    // ... 原有配置不变

    ignoreAttr: ['aria-hidden']

});

Feature v1.4.0

  1. 新增​generateMethod配置,可选svg或者canvas生成水印背景图

​​