🦍 Gorilla 🦍
Stop monkeying around and write better scripts
Intro
Gorilla is a blazing fast, TypeScript build tool for creating better GreaseMonkey scripts. It handles the complex build chain, so you don't have to.
Get started
Input
helper.ts
export const hello = (name:string) => {
console.log(`Hello ${name}!`);
}
main.ts
import { hello } from './helper';
hello('world');
package.json
...
"scripts": {
"build": "gorilla --input ./main.ts --output ./script.user.js"
},
...
Output
script.user.js
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Gorilla-built, rock-solid, Monkey script
// @updateURL
// @downloadURL
// @author You
// @include https://**
//
// Created with love using Gorilla
// ==/UserScript==
(function () {
'use strict';
function greet(name) {
console.log(`Hello, ${name}!`);
}
greet("This is a greeting");
}());
Samples
You can find a collection of samples, here.
Options
--help
)
Help (Display help menu.
eg.
gorilla --help
--input, -i
)
Input (The input handler for your script.
Note: While not required, Gorilla recommends writing your scripts in TypeScript
.
eg.
gorilla --input ./my-input-file.ts ...
--output, -o
)
Output (The input handler for your script.
Note: While not required, GreaseMonkey scripts should end with .user.js
.
eg.
gorilla --output ./my-script.user.js ...
--config, -c
)
Config (JSON input Gorilla config including GreaseMonkey metadata block data.
eg.
gorilla --config ./my-config.json ...
--quiet, -q
)
Quiet (Hide all warning messages.
eg.
gorilla --quiet true ...
Config
The config is based off of the officially supported Metadata Block items found here: https://wiki.greasespot.net/Metadata_Block
The following JSON keys are supported by GreaseMonkey:
-
author
- (string
) - Author of the script -
description
- (string
) - Description of the script -
exclude
- (string[]
) - URLs to exclude the script from -
grant
- (string[]
) - Permissions to grant to the script -
icon
- (string
) - Icon for the script -
include
- (string[]
) - URLs to include the script in -
match
- (string[]
) - URLs to match the script in -
name
- (string
) - Name of the script -
namespace
- (string
) - Namespace of the script -
noframes
- (string
) - Whether or not to run in frames -
require
- (string[]
) - Scripts to include within the script -
resource
- (string[]
) - Resources to include within the script -
version
- (string
) - Version number of the script -
updateURL
- (string
) - URL location for script updates -
downloadURL
- (string
) - URL location for script download
The config will be constructed by both the optional config
argument and with information from the package.json
file for
your current project. Some information will be take from the root of your package.json
(eg. author
, name
, etc.). Other information can be defined in a gorilla
key in your package.json
. For example:
...
"name": "This is my awesome script package.json!",
...
"gorilla": {
"include": ["this_key", "and this one"],
"updateURL": "this_url"
}
NOTE - any valid keys in the gorilla
will override anything else from the root package.json
!