GreasyForkScriptUpdate

Check update for Greasyfork userscript

Этот скрипт недоступен для установки пользователем. Он является библиотекой, которая подключается к другим скриптам мета-ключом // @require https://update.greasyfork.org/scripts/431490/1080054/GreasyForkScriptUpdate.js

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey, Greasemonkey или Violentmonkey.

Для установки этого скрипта вам необходимо установить расширение, такое как Tampermonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Userscripts.

Чтобы установить этот скрипт, сначала вы должны установить расширение браузера, например Tampermonkey.

Чтобы установить этот скрипт, вы должны установить расширение — менеджер скриптов.

(у меня уже есть менеджер скриптов, дайте мне установить скрипт!)

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

(у меня уже есть менеджер стилей, дайте мне установить скрипт!)

Автор
PYUDNG и wenku8-plus
Версия
0.4.2
Создано
27.08.2021
Обновлено
10.08.2022
Размер
4,8 КБ
Лицензия
нет данных

GreasyForkScriptUpdate.js

Check for script updates on GreasyFork.org



1. Installation

Just @require it.

2. How to use

var GFU = new GreasyForkUpdater([metarules]);
GFU.checkUpdate(<integer/string>scriptID, <string>currentversion, <function>callback[, <array>args])
Arguments:
  1. [<object/null> metarules]: An object contains property 'singles' and 'multiples'.
    1. <array> metarules.singles: An array includes all metadata keys that its value should be stored directly as a property on metadata object
    2. <array> metarules.multiples: An array includes all metadata keys that its value should always be stored as an item in an array that attached to the metadata object as its property
    3. All other properties that not included in both metarules.singles and metarules.multiples will be stored as singles or multiples depending on its apperence count. If metarules not provided, all keys will be stored in this way.
  2. <integer/string> scriptID: The GreasyFork demical script id. (For example, the scriptID of GreasyForkScriptUpdate is 431490)
  3. <string> currentversion: The current version of your script, you can get it from GM_info.script.version. It should just contains demical numbers(0123456789) and dots('.').
  4. <function> callback: The callback function. You will get three arguments while your callback function being called: <bool>update, <string>updateurl, <object>metaData
    1. <bool> update: Whether there is an update, true/false.
    2. <string> updateurl: The url latest version script.
    3. <object> metaData: An object containing all meta info of the latest script. It should like:
      {
          name: "hello world",
          version: "0.2",
          grant: "GM_xmlhttpRequest",
          connect: ["www.example.com", "example.org"],
          noframes: true,
          ...
      }
  5. [<array> args]: An arguments list that will be passed to your callback function as the 4th, 5th... argument. It should be an array. Optional.
Or, you can use this simpler one:
var GFU = new GreasyForkUpdater();
GFU.update(<integer/string>scriptID, <string>currentversion)
This will just check whether there is an update of your given script, and automatically (request your script user to) install the latest version if there is. If there is no update, then nothing happends.


3. More usage

Please refer to the source code. I've written the usage of each function.

4. READ THIS BEFORE YOU USE IT!

Be aware that one of GreasyFork's rules for posted scripts is that Scripts must not check for updates at a rate higher than once per day. Note that most user script managers will handle automatic updates, so doing it in the script is unnecessary. Scripts should also not dynamically inject another Greasy Fork-hosted script into a page, as this bypasses caching in user script managers.. Make sure you won't violate the rules all the time.