AtCoderTags_Helper

AtCoderTagsへのTag投票を、AtCoder問題ページからTagを選ぶだけで投票できるようにします。

当前为 2019-12-04 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         AtCoderTags_Helper
// @version      0.7
// @author       Null_Null
// @match        https://atcoder.jp/contests/*/tasks/*
// @match        https://*/tasks/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @require      https://code.jquery.com/ui/1.12.1/jquery-ui.js
// @grant        none
// @namespace https://github.com/null-null-programming/AtCoderTags-Helper
// @description
// AtCoderTagsへのTag投票を、AtCoder問題ページからTagを選ぶだけで投票できるようにします。
// @description AtCoderTagsへのTag投票を、AtCoder問題ページからTagを選ぶだけで投票できるようにします。
// ==/UserScript==

(function() {})();

function getContestName() {
  let contestURL = location.href;
  let contestArray = contestURL.split('/');
  return contestArray[contestArray.length - 1];
}

$('#copyright').append(`<div style="padding-top:5rem">
    <div>
        <div style="height:10;">
            <div>
                <div>
                    <h4>Tag-Vote</h4>
                </div>
                <div style="height: 20px;">
                   <form id="search">
                        <div class="input-group col-xs-11">
                            <span class="input-group-addon">Select-Tag</span>
                            <input class="form-control" id="input_tag">
                        </div>
                   </form>
                </div>
            </div>
        </div>

        <div style="height: 20px;"></div>
    </div>
</div>`);

(async function() {
  const tag = [
    'Searching', 'Greedy-Methods', 'String', 'Mathematics', 'Graph',
    'Technique', 'Construct', 'Dynamic-Programming', 'Data-Structure', 'Game',
    'Flow-Algorithms', 'Geometry'
  ];
  $('#input_tag').autocomplete({
    source: tag,
    autoFocus: true,
    delay: 0,
    minLength: 0,
    appendTo: 'menu',
    //候補をクリックすることでsubmitできるようにする
    select: function(event, ui) {
      var name = ui.item.label;
      $('#ingput_tag').val(name);
      var probleme_id = getContestName();

      window.open().location.href =
          (('https://atcoder-tags.herokuapp.com/vote_result?problem_id=' +
            probleme_id + '&tag=' + name))
    }
  });
  // input内でのEnter無効化
  $(function() {
    $(document).on('keypress', 'input:not(.allow_submit)', function(event) {
      return event.which !== 13;
    });
  });
  //日本語入力をスタートしたら無効化
  $('#input_tag').on('compositionstart', function() {
    $('#intput_tag').autocomplete('disable');
  });
  //日本語入力が確定したら有効化
  $('#input_tag').on('compositionend', function() {
    $('#input_tag').autocomplete('enable').autocomplete('search');
  });
})();