0.1.1 • Published 1 year ago

rollup-plugin-violent-monkey v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

rollup-plugin-violent-monkey

Disclaimer

rollup-plugin-violent-monkey is actively being developed. The API is rapidly changing and considered unstable. Install or upgrade at your own risk!

Template

Looking for a simple development environment? Have a look at vite-violent-monkey.

Features

  • Pass metadata directly via the options object to the plugin. Works with TypeScript or JavaScript including type completion and validation.
  • Define an external config file via the defineMetadata.
  • Automatically finds grants from all imported modules and includes them in the bundle
  • Importable type declarations for the GM_* & GM.* API supported by ViolentMonkey.

Planned

  • Add @require fields based on code imports, excluding type imports.

Usage

Installation:

# npm
npm i -D rollup-plugin-violent-monkey

# pnpm
pnpm i -D rollup-plugin-violent-monkey

Using Vite:

// vite.cofig.ts
import { defineConfig } from "vite";
import { plugin as violentMonkey } from "rollup-plugin-violent-monkey";

export default defineConfig({
    build: {
        rollupOptions: {
            plugins: [violentMonkey({
                // add your script metadata here
                //...
            })],
        },
    },
});

Using Rollup:

// rollup.config.js
import { plugin as violentMonkey } from "rollup-plugin-violent-monkey";

export default {
    plugins: [violentMonkey({
        // add your script metadata here
        //...
    })],
};

Using a standalone config file

// violentmonkey.metadata.ts or violentmonkey.metadata.js
import { defineMetadata } from "rollup-plugin-violent-monkey";

export default defineMetadata({
  name: "My Violent Script",
  downloadUrl: "github.com/myviolentscriptgist.js",
  grants: ["GM_addElement", "GM.addStyle", "window.focus"],
});

Then import it in your Rollup or Vite config:

// vite.config.ts
import { defineConfig } from "vite";
import { plugin as violentMonkey } from "rollup-plugin-violent-monkey";

import metadata from "./violentmonkey.metadata"

export default defineConfig({
    build: {
        rollupOptions: {
            plugins: [violentMonkey(metadata)],
        },
    },
});
// rollup.config.js
import { plugin as violentMonkey } from "rollup-plugin-violent-monkey";

import metadata from "./violentmonkey.metadata"

export default {
    plugins: [violentMonkey(metadata)],
};

Importing ViolentMonkey type declarations

Create a .d.ts file in the root of your source directory, and add the following:

/// <reference types="rollup-plugin-violent-monkey/context/violentmonkey" />
0.1.1

1 year ago

0.0.8-b

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.2-b

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago