Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Neos21/bookmarkletify

Repository files navigation

@neos21/bookmarkletify : Bookmarkletify

NPM Version GPR Version

JavaScript コードを Bookmarklet 形式に圧縮・変換します。

CLI Usage

$ npm install -g @neos21/bookmarkletify

# Input From File
$ bookmarkletify -i ./my-file.js
$ bookmarkletify --input ./my-file.js

# Input From Arguments
$ bookmarkletify "console.log('Test');"
javascript:(()=>{console.log("Test")})();
# Example Output

API Usage

// CJS
const bookmarkletify = require('@neos21/bookmarkletify');
// ESM
import { bookmarkletify } from '@neos21/bookmarkletify';

const input = `javascript:
  ((doc) => {
    let elem = doc.querySelector('#test');
    if(elem) {
      console.log(elem.value);
    }
  })(document);
`;

try {
  const uglified = bookmarkletify(input);
  console.log(uglified);
}
catch(error) {
  console.error(error);
}

Links