yosupo judge copy button

yosupo judgeのサンプルinputにコピーボタンをつけます。

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name     yosupo judge copy button
// @version  1
// @grant    none
// @author   tomboftime
// @namespace https://twitter.com/tomboftime
// @description yosupo judgeのサンプルinputにコピーボタンをつけます。
// @match    https://judge.yosupo.jp/problem/*
// @require  https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js
// ==/UserScript==
new ClipboardJS('.btn');

var pres = document.getElementsByTagName('pre'); 

for (var i = 0; i < pres.length; i++) {
  var pre = pres[i];
  if (pre.childElementCount == 0){
   //console.log(pre);
   var data = pre.childNodes[0].data;
   //console.log(data);
   var button = document.createElement("button");
   button.className = 'btn';
   button.innerHTML = "copy";
   button.setAttribute("data-clipboard-text",data);
    pre.parentNode.insertBefore(button, pre);
  }
}