ac-register-checker

AtCoder における企業コンテストの登録フォームにて、日本在住になっていない場合に警告を表示します。

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

作者のサイトでサポートを受ける。または、このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name        ac-register-checker
// @namespace   https://su8ru.dev
// @version     0.1.0
// @description AtCoder における企業コンテストの登録フォームにて、日本在住になっていない場合に警告を表示します。
// @author      subaru <[email protected]>
// @supportURL  https://twitter.com/su8ru_
// @license     MIT
// @match       https://atcoder.jp/contests/*/register
// ==/UserScript==

(() => {
  'use strict';
  const registerForm = document.forms[1];
  const insertAlert = () => {
    const alertHtml = (n) => `<div id="ac-register-checker-alert-${n}" class="alert alert-danger" role="alert"><p style="font-weight:bold;">「日本国内在住か?」が「はい」になっていません!</p></div>`;
    registerForm.querySelector('button').insertAdjacentHTML('beforebegin', alertHtml(1));
    document.querySelector('.form-group').insertAdjacentHTML('afterend', alertHtml(2));
    registerForm.querySelector('button').classList.replace('btn-primary', 'btn-danger');
  }
  const removeAlert = () => {
    document.querySelector('#ac-register-checker-alert-1').remove();
    document.querySelector('#ac-register-checker-alert-2').remove();
    registerForm.querySelector('button').classList.replace('btn-danger', 'btn-primary')
  }
  const onFormChange = (e) => {
    const value = registerForm['日本国内在住か?'].value;
    if (value === 'No') insertAlert();
    else removeAlert();
  };
  registerForm.addEventListener('change', onFormChange);
  onFormChange();
})();