atcoder-sidemenu

AtCoderページの横に要素を乗せられるSidemenuを追加します。

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/386715/715444/atcoder-sidemenu.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 or Violentmonkey 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!)

Аўтар
keymoon
Версія
0.0.1.20190627175831
Створаны
23.06.2019
Абноўлены
27.06.2019
Памер
25.2 КБ
Ліцэнзія
Н/Д

概要

AtCoderページ上にsidemenuを表示し、その上に要素を載せることを可能にするライブラリです。

ソースについて

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

使い方

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

// @require https://greasyfork.org/scripts/386715-atcoder-sidemenu/code/atcoder-sidemenu.js?version=715439

素のJavaScriptで開発する場合

ツールなどを用いずにこのライブラリを使用する場合は、グローバルに存在しているsidemenuオブジェクトの中に格納されているオブジェクトやクラスを用いることになります。 例えば、以下のようなスクリプトを実行するとSideMenuに「hello,world!」とalertを出すボタンの乗った要素を追加します。

sidemenu.sidemenu.addElement(new sidemenu.SideMenuElement("id","Title",/.*/,"<button id='button1'>button</button>",() => $('#button1').click(() => alert("hello,world!"))));

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

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

externals: {
    "atcoder-sidemenu": "sidemenu",
}

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

import { sidemenu, SideMenuElement } from "atcoder-sidemenu";
sidemenu.addElement(new SideMenuElement("id","Title",/.*/,"<button id='button1'>button</button>",() => $('#button1').click(() => alert("hello,world!"))));

と書くことができるようになります。