ac-register-checker

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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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();
})();