Greasy Fork is available in English.

Greasy Fork API

Parse information on greasyfork.org

Този скрипт не може да бъде инсталиран директно. Това е библиотека за други скриптове и може да бъде използвана с мета-директива // @require https://greasyfork.org/scripts/445697-greasy-fork-api/code/Greasy%20Fork%20API.js?version=1055543

Автор
NotYou
Версия
1.0.0
Създаден
29.05.2022
Обновен
29.05.2022
Лиценз
LGPL-3.0

Greasy Fork API

Description:

Parse information on greasyfork.org

How to use:

Let's start with adding @require in your script meta section! Add in your script this:

// @require https://greasyfork.org/scripts/445697/code/index.js

So in final you are going to get something like this:

// ==UserScript==
// @name New Userscript (Example)
// @namespace -
// @description try to take over world!
// @author Example
// @include *example.com/*
// @require https://greasyfork.org/scripts/445697/code/index.js
// @license GPL-3.0-or-later
// @grant none
// ==/UserScript==

Next, you need to add a variable that with equal to class GreasyFork. Example:

const GF = new GreasyFork

parseScriptElement

Returns properties of script element if it exists, such as: Name, ID, version, language, installs etc.

var myScript = GF.parseScriptElement(document.querySelector('[data-script-id]'))
console.log(myScript.id) // some number

parseScriptCodeMeta

Returns array with script meta blocks and their values, example:

GF.parseScriptCodeMeta(`
// ==UserScript==
// @name        New Userscript (Example)
// @description try to take over world!
// ==/UserScript==
`)

/* will return this:
[{
    meta: "@name",
    value: "New Userscript (Example)"
},
{
    meta: "@description",
    value: "try to take over world!"
}]
*/

ls

Returns object with scripts, libraries and browsed script if they exist.

GF.ls()

/* will return
{
browsed: [...],
libraries: [...],
scripts: [...]
}
if function can't find elements to parse, then it returns null.
*/

get

This is the parent function that returns an object with different functions.

GF.get()

get.script

This is the parent function that returns an object with different functions.

GF.get().script()

action

install (Note: standard language is JS, if you are NOT going to install user style, then just do not specify "lang" key.)

GF.action('install', {
    id: 439627,
    lang: 'css'
})

signout

GF.action('signout')

Asynchronous functions

get.script.code

Returns script code.

var code = await GF.get().script().code(437291)
console.log(code)

Note: Can be used with parseScriptCodeMeta:

var code = await GF.get().script().code(437291)
console.log(GF.parseScriptCodeMeta(code))

get.script.history

Returns script versions, time of versions and descriptions.

await GF.get().script().history(437291)

get.script.feedback

Returns script feedback: rating, text and meta info.

await GF.get().script().feedback(437291)

get.script.stats

Returns script stats (installs and update checks) in different days.

await GF.get().script().stats(437291)

get.script.info

Returns script information from itself main page.

await GF.get().script().info(437291)

get.script.set

Returns result from script set.

await GF.get().script().set(10699, {
    locale: 'zh-CN',
    page: 1
})

Also you can turn off locale filter:

await GF.get().script().set(10699, {
    localeFilter: 0,
    page: 1
})

get.user

Returns user's information such as:

ID, Nickname, scripts, libaries, script sets, recent comments etc.

await GF.get().user(824432)

get.search

Returns search result of some content types.

script

await GF.get().search('Open Redirector', 'script', {
    locale: 'ro',
    sort: 'daily_installs',
    page: 1
})

library

await GF.get().search('Random - Lib', 'library', {
    sort: 'name'
})

user

await GF.get().search('NotYou', 'user', {
    asJSON: true
})

list

await GF.get().search('', 'list') // ["script", "library", "user", "list"]