您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Customize your contester
当前为
// ==UserScript== // @name IITU Contester tools // @namespace https://greasyfork.org/ru/users/77226 // @version 0.2 // @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------------------------------------------------------------------ // http://www.devign.me/greasemonkey-gm_getvaluegm_setvalue-functions-for-google-chrome/ 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("ctds", "text"); //-------------------------MAIN---------------------------------------------------------------------- $(document).ready(function() { initSettingsBlock(); initSettingsButton(); /* $("select#ctcsel").change(function() { var compilerSelect = document.getElementById("ctcsel"); var selected = compilerSelect.options[compilerSelect.selectedIndex].value; // document.getElementById("ctcsel").options[document.getElementById("ctcsel").selectedIndex].value defaultCompiler = selected; }); */ $("button#save").click(function() { defaultCompiler = document.getElementById("ctcsel").options[document.getElementById("ctcsel").selectedIndex].value; GM_setValue("ctdc", defaultCompiler); }); $("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 //$('#m_acompiler option:eq(0)').removeAttr("selected"); console.log("SetComp: " + dc); 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 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":"200px", "width":"150px", "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":"160px", }); $("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); //----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 $("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; }