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

fuck-smartisan

v0.0.4

Published

Fuck Smartisan

Readme

Fuck Smartisan

这是个恶意的项目,作者知道自己是错的,但并不会悔改。所以请勿费力批评。

本项目用于拒绝锤子手机,请在明确认知到自己是在作恶的情况下使用。

另外,除非你有相应的权力,否则请勿在公司项目中使用。

基本使用

您可以简单地在项目代码中引入本项目来实现拒绝锤子手机的访问

import fuckSmartisan from 'fuck-smartisan'

fuckSmartisan()

fuckSmartisan 函数将清理 html 标签下所有内容,并替换为一行 ‘因开发者个人的偏见,本项目不对锤子手机用户开放。’

你也可以自定义的提示信息,支持以下几种用法(第二、三条将折行显示)

fuckSmartisan('本项目开发者精力有限,暂不准备兼容锤子手机')
fuckSmartisan('本项目内含播放声音的内容\n为避免影响您使用 TNT\n特此主动屏蔽')
fuckSmartisan(['锤子万岁', '太君威武'])

PS: 为了最佳的阅读体验,建议单行不超过 50 字

自定义使用

本项目提供了简单的 isSmartisanOS 函数,您可以引入此函数来判断一个 userAgent 字符串是否来自锤子手机,从而实现定制化的服务。

用法:

import { isSmartisanOS } from 'fuck-smartisan'

isSmartisanOS() // 浏览器环境下可不传参,将自动获取 navigator.userAgent 用于判断
isSmartisanOS(ctx.userAgent)

示例:

function showPrice(price) {
  if (isSmartisanOS()) {
    return [`原价: ${price * 3}`, `锤子用户专享价:${price * 2.5}`]
  } else {
    return [`原价: ${price * 1.1}`, `现时特惠:${price}`]
  }
}

xxxxx.innerText = showPrice(100)

作为 Vue 插件使用

本项目提供了 Vue 插件,该插件将在 Vue 原型上添加一个 $isSmartisanOS 属性用于判断是否锤子手机

引入:

import Vue from 'vue'
import vIsSmartisanOS from 'fuck-smartisan/dist/v-is-smartisan-os'

Vue.use(asyncValidatorPromisify)

使用:

<template>
  <div class="sku">
    <h1 class="sku__title">Apple iPhone X (A1865) 256G 深空灰色 三网通</h1>
    <img class="sku__image" src="xxxx" />
    <v-button class="sku__btn" v-if="$isSmartisanOS" :disabled="$isSmartisanOS">您的手机远强于该手机,无需购买</v-button>
    <v-button class="sku__btn" v-else :disabled="$isSmartisanOS" @click="buy(skuInfo)">点击购买</v-button>
  </div>
</template>
export default {
  name: 'beginning-info',
  // ......
  methods: {
    async getCoupons() {
      if (this.$isSmartisanOS) {
        return []
      }
      try {
        const coupons = await queryCoupons({ expried: false })
        return coupons
      } catch (e) {
        alert('网络异常')
        return []
      }
    },
  },
}

作为 Koa 插件使用

本项目提供了 Koa 插件,该中间件将根据客户端的 user-agent 判断是否锤子手机,进而 ctx 上添加一个 isSmartisanOS 属性。

import Koa from 'koa' // koa 2
import koaFuckSmartisan from 'fuck-smartisan/dist/koa-fuck-smartisan'

Vue.use(koaFuckSmartisan())

app.use(ctx => {
  if (ctx.isSmartisanOS) {
    ctx.status = 301
    ctx.body = '锤子手机售价低于2500,我是你孙子'
    ctx.redirect('http://www.smartisan.love')
  }
})

您也可以向插件传入一个 config 来直接中断 koa 剩余业务逻辑,直接返回一行 “因开开发者能力有限,本页面不对锤子手机进行兼容,理解万岁。” 给锤子客户端:

import Koa from 'koa' // koa 2
import koaFuckSmartisan from 'fuck-smartisan/dist/koa-fuck-smartisan'

Vue.use(koaFuckSmartisan({ forbid: true }))

app.use(async (ctx, next) => {
  // This will not run when hammer phone visit
  ctx.body = "Hello, Phone"
  await next()
})

当然,自定义返回信息也是可以的:

import Koa from 'koa' // koa 2
import koaFuckSmartisan from 'fuck-smartisan/dist/koa-fuck-smartisan'

const SmartisanResponse = {
  status: 404,
  body: '锤子的销量不到 40 万,显然是一个可忽视的机型',
}

Vue.use(koaFuckSmartisan({ forbid: true, response: SmartisanResponse  }))

在命令行中使用

本项目提供了命令行工具,以便在 shell 中使用

$ is-smartisan --help

usage: is-smartisan [-i|<data>] [--help]

-i      接收标准输入
--help  显示帮助信息

example:
$ is-smartisan "Mozilla/5.0 (Linux; U; Android 6.0.1; zh-cn; SM919 Build/MXB48T) Ap..."
$ cat user-agent.text | is-smartisan -i

示例:

NGX_LOG=/data/logs/nginx-access.log

while read LINE; do
  is-smartisan "$LINE" && push-black-list "$LINE" || push-white-list "$LINE"
done < "$NGX_LOG"

贡献代码

鉴于本人可能跟不上 TNT 用户的开发效率,所以提交 PR 的同时,请附上自己的屏幕截图,证明自己不是 TNT 用户。