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

@xiaohuohumax/bookmark-script

v4.0.3

Published

基于 rollup 的书签脚本打包工具 Bookmarklet Cli

Downloads

3

Readme

@xiaohuohumax/bookmark-script

基于 vite Rollup 的书签脚本打包工具 Bookmarklet Cli

作用

alert('Hello, World!');

将上面代码打包成类型以下浏览器书签链接

javascript:(function(){alert("Hello, World!");})();void(0);

使用

1. 模板创建

npm create @xiaohuohumax/bookmark-script
# 选择模板

2. 自行创建

添加依赖

npm i @xiaohuohumax/bookmark-script

编写配置文件

project
 ├── bm.config.ts
 ├── package.json
 ├── src
 │   ├── index.ts
 │   └── time.png
 └── tsconfig.json
// bm.config.ts 或 bm.config.js
import { defineConfig } from '@xiaohuohumax/bookmark-script';

export default defineConfig({
  // 输出目录
  outDir: 'dist',
  // 书签打包结构, 以及书签脚本入口文件, 图标等
  bms: [
    {
      name: 'show time',
      description: ''
      href: 'src/time.ts',
      icon: 'src/time.png'
    }
  ],
  // 其他必要配置
  ...
});

添加智能提示 (可选)

tsconfig.json

{
  "compilerOptions": {
    "types": [
      "@xiaohuohumax/bookmark-script/client"
    ],
  },
}

编写书签脚本

// index.ts
// 也可以使用第三方库 比如: axios, sweetalert2等
// import axios from 'axios';
alert(new Date());

打包构建

修改 package.json

使用 npx bookmark-script --help 可查看其他参数

{
  "scripts": {
    "build": "bookmark-script"
  },
}

输出结果

dist
 ├── favorites.html     // 可以通过浏览器直接导入
 └── show time
     ├── bookmark.txt   // 书签脚本版本(手动添加至书签)
     └── console.js     // 控制台版本(F12执行即可)

简单示例

最后

玩的开心 🎉🎉🎉🎉