Submit Text on CSES

Submit on CSES with pasting

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.

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

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         Submit Text on CSES
// @namespace    plantt
// @version      2025-11-27
// @description  Submit on CSES with pasting
// @author       You
// @match        https://cses.fi/problemset/submit/*
// @grant        none
// @license      GPL
// ==/UserScript==

let fileInput = document.querySelector("input[name=file]");
let lang = document.getElementById("lang");
let textarea = document.createElement("textarea");
fileInput.parentElement.parentElement.insertBefore(textarea, fileInput.parentElement.nextElementSibling);
if (localStorage.getItem("cses-lang")) {
    lang.value = localStorage.getItem("cses-lang");
    lang.dispatchEvent(new Event("change"));
}
lang.onchange = () => localStorage.setItem("cses-lang", lang.value);
textarea.oninput = () => {
    let datat = new DataTransfer;
    datat.items.add(new File([textarea.value], "source.txt"));
    fileInput.files = datat.files;
};