您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Customize your contester
当前为
// ==UserScript== // @name IITU Contester tools // @namespace https://greasyfork.org/ru/users/77226 // @version 0.3 // @description Customize your contester // @author Diasonti // @match http://contester.iitu.kz:*/* // @license Creative Commons; http://creativecommons.org/licenses/by/4.0/ // @require https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js // @grant none // ==/UserScript== //-----------------GM_set/getValue fix------------------------------------------------------------------ if (!this.GM_getValue || (this.GM_getValue.toString && this.GM_getValue.toString().indexOf("not supported")>-1)) { this.GM_getValue=function (key,def) { return localStorage[key] || def; }; this.GM_setValue=function (key,value) { localStorage[key]=value; }; this.GM_deleteValue=function (key) { return delete localStorage[key]; }; } //----------------Global Variables------------------------------------------------------------------- var defaultCompiler = GM_getValue("ctdc", "cpp"); var defaultSubmType = GM_getValue("ctdsb", "text"); var defaultStudent = GM_getValue("ctdst", "Admin"); //-------------------------MAIN---------------------------------------------------------------------- $(document).ready(function() { initSettingsBlock(); initSettingsButton(); $("button#save").click(function() { saveSettings(); }); if(document.getElementsByTagName('title')[0].innerHTML==="Contester 2.4" || document.getElementsByTagName('title')[0].innerHTML==="Sign in - Contester") { $("body").click(function() { setStudent(defaultStudent); }); } else $("body").click(function() { setSubmType(defaultSubmType); setComp(defaultCompiler); }); }); //----------------------------FUNCTIONS------------------------------------------------------------- function setSubmType(st) {//----SET SUBMISSION TYPE if(st==="file") { show('m_code_as_file'); hide('m_code_as_text'); obj('m_take').value='file'; //to file } else if(st==="text") { show('m_code_as_text'); hide('m_code_as_file'); obj('m_take').value='text'; // to text } return; } function setComp(dc) {//----SET COMPILER if(dc=="cpp") { $('#m_acompiler option:contains("C++ (C++)")').attr('selected', true); } else if(dc==="pascal") { $('#m_acompiler option:contains("Pascal (Free Pascal 2.6.0)")').attr('selected', true); } return; } function setStudent(ds) { $('#sgr_uid option:contains(' + ds + ')').attr('selected', true); $('#m_uid option:contains(' + ds + ')').attr('selected', true); return; } function initSettingsBlock() {//----SETTINGS BLOCK var set = document.createElement("div"); document.body.appendChild(set); set.id = "ctsettings"; $("div#ctsettings").css({ "position":"fixed", "bottom":"0", "right":"0", "height":"350px", "width":"300px", "background":"white", "border":"1px solid black", }); var mainb = document.createElement("div"); var footb = document.createElement("div"); document.getElementById("ctsettings").appendChild(mainb); document.getElementById("ctsettings").appendChild(footb); mainb.id = "mainb"; footb.id = "footb"; $("div#mainb").css({ "height":"310px", }); $("div#footb").css({ "height":"40px", }); //----Main Section var header = document.createElement("p"); document.getElementById("mainb").appendChild(header); header.id = "ctheader"; header.innerHTML = "Contester Tools"; $("p#ctheader").css({ "margin":"2px" }); var compilerLabel = document.createElement("p"); document.getElementById("mainb").appendChild(compilerLabel); compilerLabel.id = "ctclabel"; compilerLabel.innerHTML = "Default compiler: <br>"; var compilerSelect = document.createElement("select"); document.getElementById("mainb").appendChild(compilerSelect); compilerSelect.id = "ctcsel"; /* var defopt = document.createElement("option"); document.getElementById("ctcsel").appendChild(defopt); defopt.id = "def"; defopt.innerHTML = "def"; $("option#def").attr("value","java"); */ var cppopt = document.createElement("option"); document.getElementById("ctcsel").appendChild(cppopt); cppopt.id = "cpp"; cppopt.innerHTML = "C++"; $("option#cpp").attr("value","cpp"); var pascalopt = document.createElement("option"); document.getElementById("ctcsel").appendChild(pascalopt); pascalopt.id = "pascal"; pascalopt.innerHTML = "Pascal"; $("option#pascal").attr("value","pascal"); $("option#" + defaultCompiler).attr('selected', true); var submLabel = document.createElement("p"); document.getElementById("mainb").appendChild(submLabel); submLabel.id = "ctsblabel"; submLabel.innerHTML = "Default submission type: <br>"; var submSelect = document.createElement("select"); document.getElementById("mainb").appendChild(submSelect); submSelect.id = "ctsbsel"; var textopt = document.createElement("option"); document.getElementById("ctsbsel").appendChild(textopt); textopt.id = "textopt"; textopt.innerHTML = "Text"; $("option#textopt").attr("value","text"); var fileopt = document.createElement("option"); document.getElementById("ctsbsel").appendChild(fileopt); fileopt.id = "fileopt"; fileopt.innerHTML = "File"; $("option#fileopt").attr("value","file"); $("option#" + defaultSubmType + "opt").attr('selected', true); var studentLabel = document.createElement("p"); document.getElementById("mainb").appendChild(studentLabel); studentLabel.id = "ctslabel"; studentLabel.innerHTML = "Default student: <br>"; if(document.getElementById("sgr_uid") !== null) { var studentsList = document.getElementById("sgr_uid"); var studentSelect = studentsList.cloneNode(true); document.getElementById("mainb").appendChild(studentSelect); studentSelect.id = "ctssel"; $('#ctssel').removeAttr('name class onchange'); $('#ctssel option:contains(' + defaultStudent + ')').attr('selected', true); } else { var studentl = document.createElement("select"); document.getElementById("mainb").appendChild(studentl); studentl.id = "studentl"; var student = document.createElement("option"); document.getElementById("studentl").appendChild(student); student.innerHTML = defaultStudent; $("select#studentl").attr("disabled", "true"); } //----Foot Bar var savebutton = document.createElement("button"); var cancelbutton = document.createElement("button"); document.getElementById("footb").appendChild(savebutton); document.getElementById("footb").appendChild(cancelbutton); savebutton.id = "save"; cancelbutton.id = "cancel"; savebutton.innerHTML="Save"; cancelbutton.innerHTML="Cancel"; $("button#save").css({ "position":"absolute", "left":"7px", "bottom":"4px" }); $("button#cancel").css({ "position":"absolute", "right":"7px", "bottom":"4px" }); $("button#cancel").attr("onclick",'$("div#ctsetb").show(); $("div#ctsettings").hide();'); //-----Hide Block by default $("div#ctsettings").hide(); return; } function initSettingsButton() {//----SETTINGS BUTTON var setB = document.createElement("div"); document.body.appendChild(setB); setB.id = "ctsetb"; $("div#ctsetb").css({ "position":"fixed", "bottom":"0", "right":"0", "height":"40px", "width":"40px", "background":"pink", "border":"2px solid black", "opacity":"0.5" }); $("div#ctsetb").attr("onclick",'$("div#ctsetb").hide(); $("div#ctsettings").show();'); return; } function saveSettings() { defaultCompiler = document.getElementById("ctcsel").options[document.getElementById("ctcsel").selectedIndex].value; GM_setValue("ctdc", defaultCompiler); defaultSubmType = document.getElementById("ctsbsel").options[document.getElementById("ctsbsel").selectedIndex].value; GM_setValue("ctdsb", defaultSubmType); defaultStudent = document.getElementById("ctssel").options[document.getElementById("ctssel").selectedIndex].innerHTML; GM_setValue("ctdst", defaultStudent); return; }