Greasy Fork API

Get information from Greasy Fork and do actions in it.

אין להתקין סקריפט זה ישירות. זוהי ספריה עבור סקריפטים אחרים // @require https://update.greasyfork.org/scripts/445697/1747795/Greasy%20Fork%20API.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

יוצר
NotYou
גרסה
3.0.0
נוצר
29-05-2022
עודכן
03-02-2026
Size
9.67 קילו-בייט
רישיון
LGPL-3.0

Greasy Fork API

Description:

Get data from Greasy Fork, or/and do actions on Greasy Fork

Dependencies

  • Zod
  • GM.xmlHttpRequest
  • GM.openInTab

Docs

Getting started

Constructor only accepts one parameter, which determines if the hostname should be 'api.greasyfork.org' (pass down nothing since it is value by default or false to explicitly choose this one) or 'api.sleazyfork.org' (pass down true for this one)

const GF = new GreasyFork()

That's it for setting up the instance.

Types

These types are not real typescript types, but rather just their representation. (I used zod for runtime types)

IdStringFormat

Positive integer or numeric string that doesn't start with 0 (regex for the string: /^(?!0)\d+$/)

QueryFormat

An optional string

PageFormat

An optional integer

FilterLocaleFormat

An optional boolean

ScriptsQuerySchema

interface ScriptsQuerySchema {
  q?: QueryFormat,
  page?: PageFormat,
  filter_locale?: FilterLocaleFormat
  sort?: "total_installs" | "ratings" | "created" | "updated" | "name"
}

ScriptSetsQuerySchema

Same as ScriptsQuerySchema, but has property set which has type IdStringFormat

interface ScriptSetsQuerySchema extends ScriptsQuerySchema {
  set: IdStringFormat
}

LibrariesQuerySchema

Same as ScriptsQuerySchema, but doesn't have sorting by total_installs or ratings

interface LibrariesQuerySchema {
  q?: string,
  page?: number,
  sort?: "created" | "updated" | "name"
}

UsersQuerySchema

interface UsersQuerySchema {
  q?: QueryFormat,
  page?: PageFormat,
  sort?: "name" | "daily_installs" | "total_installs" | "ratings" | "scripts" | "created_scripts" | "updated_scripts",
  authors?: boolean
}

InstallSchema

interface InstallSchema {
  id: IdStringFormat,
  type?: "js" | "css" // "js" by default
}

Instance Properties

script

Contains methods to get particular script information. (for example script history)

Methods (of the script property):

getData(id: IdStringFormat): Promise<object>

Gets info about the script

const data = await GF.script.getData(1)

/* Response Example:
{
    "id": 1,
    "daily_installs": 0,
    "total_installs": 311,
    "fan_score": "82.4",
    "good_ratings": 18,
    "ok_ratings": 0,
    "bad_ratings": 0,
    "created_at": "2014-02-18T19:51:43.000Z",
    "code_updated_at": "2023-11-22T00:50:37.000Z",
    "namespace": "http://userstyles.org",
    "support_url": null,
    "contribution_url": null,
    "contribution_amount": null,
    "users": [
        {
            "id": 1,
            "name": "JasonBarnabe",
            "created_at": "2014-02-18T19:49:27.000Z",
            "url": "https://greasyfork.org/users/1-jasonbarnabe"
        }
    ],
    "name": "Greasemonkey/Tampermonkey/Violentmonkey test style",
    "description": "If you install this and all text turns red, then things are working.",
    "url": "https://greasyfork.org/scripts/1-greasemonkey-tampermonkey-violentmonkey-test-style",
    "code_url": "https://update.greasyfork.org/scripts/1/GreasemonkeyTampermonkeyViolentmonkey%20test%20style.user.js",
    "code_size": 981,
    "license": null,
    "version": "20231121.2",
    "locale": "en"
}

getCode(id: IdStringFormat): Promise<string>

Gets all the code of the user-script

const code = await GF.script.getCode(1)

/*
// ==UserScript==
// @name          Greasemonkey/Tampermonkey/Violentmonkey test style
// @namespace     http://userstyles.org
// @description   If you install this and all text turns red, then things are working.
// @author        JasonBarnabe
// @homepage      http://greasyfork.org/scripts/1
// @run-at        document-start
// @version       20231121.2
// @include       *

...

    var node = document.createElement("style");
    node.type = "text/css";
    node.appendChild(document.createTextNode(css));
    var heads = document.getElementsByTagName("head");
    if (heads.length > 0) {
        heads[0].appendChild(node); 
    } else {
        // no head yet, stick it whereever
        document.documentElement.appendChild(node);
    }
}
})();
*/

getMeta(id: IdStringFormat): Promise<string>

Gets only the metadata of the user-script

const meta = await GF.script.getMeta(1)

/*
// ==UserScript==
// @name          Greasemonkey/Tampermonkey/Violentmonkey test style
// @namespace     http://userstyles.org
// @description   If you install this and all text turns red, then things are working.
// @author        JasonBarnabe
// @homepage      http://greasyfork.org/scripts/1
// @run-at        document-start
// @version       20231121.2
// @include       *
// ==/UserScript==
*/

getHistory(id: IdStringFormat): Promise<object>

Gets version history of the user-script

const history = await GF.script.getHistory(1)

/*
[
    {
        "version": "20231121.2",
        "created_at": "2023-11-22T00:50:38.000Z",
        "url": "https://api.greasyfork.org/en/scripts/1-greasemonkey-tampermonkey-violentmonkey-test-style?version=1284072",
        "code_url": "https://greasyfork.org/scripts/1-greasemonkey-tampermonkey-violentmonkey-test-style/code/GreasemonkeyTampermonkeyViolentmonkey%20test%20style.user.js?version=1284072"
    },

    ...

    {
        "version": "1.20140218195143",
        "created_at": "2014-02-18T19:51:43.000Z",
        "url": "https://api.greasyfork.org/en/scripts/1-greasemonkey-tampermonkey-violentmonkey-test-style?version=1",
        "code_url": "https://greasyfork.org/scripts/1-greasemonkey-tampermonkey-violentmonkey-test-style/code/GreasemonkeyTampermonkeyViolentmonkey%20test%20style.user.js?version=1"
    }
]
*/

getStats(id: IdStringFormat): Promise<object>

Gets stats of the user-script (installs, update checks)

/*
{
    "2014-02-18": {
        "installs": 1,
        "update_checks": null
    },
    "2014-02-19": {
        "installs": 5,
        "update_checks": null
    },

    ...


    "2026-02-02": {
        "installs": 0,
        "update_checks": 0
    },
    "2026-02-03": {
        "installs": 0,
        "update_checks": 0
    }
}
*/

getStatsCsv(id: IdStringFormat): Promise<string>

Gets stats of the user-script (installs, update checks), but in csv format

const statsCsv = await GF.script.getStatsCsv(1)

/*
Response is too big to show
*/

Instance Methods

getScripts(options: ScriptsQuerySchema): Promise<object[]>

Queries 100 scripts at once using specified parameters

await GF.getScripts() // just get top scripts

await GF.getScripts({ q: 'test' }) // get scripts with relevant keyword


await GF.getScripts({
  q: 'test',
  page: 2 // pages start from 1, not from 0
})

await GF.getScripts({
  q: 'test',
  filter_locale: false, // show all results regardless of the language
  sort: 'name' // also, sort them by the name
})

getScriptSet(options: ScriptSetsQuerySchema): Promise<object[]>

Works same as getScripts, but just queries it from created sets.

GF.getScriptSet({
  set: 1,
  filter_locale: false,
  sort: 'created',
  page: 3
})

getLibraries(options: LibrariesQuerySchema): Promise<object[]>

Queries the libraries.

The only real difference between script objects, is that value of code_url contains only the particular version of the library, not the always version.

await GF.getLibraries()

await GF.getLibraries({
  page: 2
})

await GF.getLibraries({
  q: 'GM',
  sort: 'name'
})

getUserData(id: IdStringFormat): Promise<object>

await GF.getUserData(1)

/*
{
    "id": 1,
    "name": "JasonBarnabe",
    "created_at": "2014-02-18T19:49:27.000Z",
    "url": "https://greasyfork.org/users/1-jasonbarnabe",
    "scripts": [...]
}
*/

getUsers(options: UsersQuerySchema): Promise<object[]>

Queries 100 users per request

await GF.getUsers()

await GF.getUsers({
  q: 'john',
  page: 2,
  sort: 'name'
})

await GF.getUsers({
  author: true, // query script authors
  sort: 'created_scripts'
})

await GF.getUsers({
  author: false // unlike await GF.getUsers(), this query skips the script authors
})

/*
[
    {
        "id": 1567324,
        "name": "ambiel9687",
        "created_at": "2026-02-03T08:13:26.000Z",
        "url": "https://greasyfork.org/users/1567324-ambiel9687"
    },

    ...

    {
        "id": 1567224,
        "name": "Brandon Velasquez Morales",
        "created_at": "2026-02-03T01:45:59.000Z",
        "url": "https://greasyfork.org/users/1567224-brandon-velasquez-morales"
    }
]
*/

signOut(): Promise<void>

Signs out of the Greasy Fork account

await GF.signOut()

installUserScript(options: InstallSchema): void

Installs user-script.

Note: specifying "js" type for user-script doesn't do anything since this is default option

GF.installUserScript({
  id: 437291
})

GF.installUserScript({
  id: 439627,
  type: 'css' // you can specify "js" for user-styles
})