atcoder-userscript-libs

AtCoderのページ上で動作するスクリプト用のライブラリです。

Tính đến 07-07-2019. Xem phiên bản mới nhất.

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @require https://update.greasyfork.org/scripts/386712/715479/atcoder-userscript-libs.js

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

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

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.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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!)

Tác giả
keymoon
Phiên bản
0.0.1.20190705171646
Đã tạo
23-06-2019
Đã cập nhật
07-07-2019
Kích thước
20 KB
Giấy phép
N/A

概要

AtCoder上で動くUserScriptを補助するライブラリです。

ソースについて

このライブラリは複数ファイルを1つにまとめたものです。ソースの詳細はGitHubを参照してください。一行目以外同一のものをビルド可能なソースコードを公開しています。(一行目はグローバルへエクスポートするために改変を行っています。)

使い方

まず、UserScriptのHeaderに以下のような行を追加してください。

// @require https://greasyfork.org/scripts/386712-atcoder-userscript-libs/code/atcoder-userscript-libs.js?version=715082

素のJavaScriptで開発する場合

ツールなどを用いずにこのライブラリを使用する場合は、グローバルに存在しているusLibsオブジェクトの中に格納されているライブラリ内にあるオブジェクトやクラスを用いることになります。 例えば、以下のようなコードを実行するとalertでdiverta2019-2のコンテスト情報を表示します。

var contestInformation = await usLibs.contestInformation.fetchContestInformation("diverta2019-2");
alert(JSON.stringify(contestInformation));

モジュールバンドラを用いる場合

WebPack等のモジュールバンドラを用いる場合は、公開しているパッケージをプロジェクトにインストールすることをお勧めします。 インストールした後、webpack.config.jsでexternalの記述を以下のようにしてください。:

externals: {
    "atcoder-userscript-libs": "usLibs",
    "atcoder-userscript-libs/src/libs/data": "usLibs.data",
    "atcoder-userscript-libs/src/libs/rating": "usLibs.rating",
    "atcoder-userscript-libs/src/libs/global": "usLibs.global",
    "atcoder-userscript-libs/src/libs/contestInformation": "usLibs.contestInformation"
}

そうすることで依存関係の中にuserscript-libsを取り込め、

import { fetchContestInformation } from "atcoder-userscript-libs/src/libs/contestInformation";
var contestInformation = await fetchContestInformation("diverta2019-2");
alert(JSON.stringify(contestInformation));

と書けるようになります。