AtCoderDevotionScript

Write contestID and problem to the clipboard

Verze ze dne 09. 11. 2020. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         AtCoderDevotionScript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Write contestID and problem to the clipboard
// @author       imomo
// @match        https://atcoder.jp/contests/*/tasks/*
// @grant        none
// ==/UserScript==

onkeydown = function(){
  if(event.ctrlKey&&event.keyCode==81){
      //問題ページのURLを取得
      var contestUrl = location.href;
      //コンテストのパスのみ切り出し
      var problemPass = contestUrl.substr(contestUrl.lastIndexOf("/")+1);
      //contestID及び問題種別を格納
      var contestID = problemPass.substr(0,problemPass.length - 2);
      var problem =problemPass.substr(-1);

      // 空div 生成
      var tmp = document.createElement("div");
      // 選択用のタグ生成
      var pre = document.createElement('pre');

      // 親要素のCSSで user-select: none だとコピーできないので書き換える
      pre.style.webkitUserSelect = 'auto';
      pre.style.userSelect = 'auto';

      tmp.appendChild(pre).textContent = contestID + " " + problem;

      // 要素を画面外へ
      var s = tmp.style;
      s.position = 'fixed';
      s.right = '200%';

      // body に追加
      document.body.appendChild(tmp);
      // 要素を選択
      document.getSelection().selectAllChildren(tmp);

      // クリップボードにコピー
      document.execCommand("copy");

      // 要素削除
      document.body.removeChild(tmp);
  }
}