├── README.md ├── match ├── README.md └── script.user.js └── script.user.js /README.md: -------------------------------------------------------------------------------- 1 | # cf-code 2 | > 推荐使用暴力猴,Tempermonkey会出现只能查看第一页代码的问题 3 | 4 | # 由于Codeforces长期启用Cloudflare,已经无法正常抓取代码数据,由此此项目已失效。 5 | 6 | 7 | 在没有登录或者没有开启Coach模式的时候查看Codeforces GYM的代码 8 | 9 | 未使用脚本的情况下,登录账号未开启Coach模式或者未登录时提交列表第一列的编号是纯文本。 10 | 11 | ![未开启脚本](https://cdn.dianhsu.com/img/2022-06-06-12-51-50.png) 12 | 13 | 开启脚本后,提交列表的第一列变成了超链接。 14 | 15 | ![开启脚本后](https://cdn.dianhsu.com/img/2022-06-06-12-52-37.png) 16 | 17 | 点击这个超链接就可以看到代码了。 18 | 19 | 20 | PS:如果是私有的比赛,由于请求代码的账号没有权限,所以无法获取代码。 21 | -------------------------------------------------------------------------------- /match/README.md: -------------------------------------------------------------------------------- 1 | # Codeforces Match Enhancer 2 | 3 | auto insert problem id and language in match. 4 | -------------------------------------------------------------------------------- /match/script.user.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name Codeforces Match Enhancer. 3 | // @namespace Violentmonkey Scripts 4 | // @match https://m1.codeforces.com/contest/*/submit 5 | // @match https://m2.codeforces.com/contest/*/submit 6 | // @match https://m3.codeforces.com/contest/*/submit 7 | // @grant none 8 | // @version 1.2 9 | // @author dianhsu 10 | // @license MIT 11 | // @run-at document-idle 12 | // @downloadURL https://raw.githubusercontent.com/dianhsu/cf-code/main/match/script.user.js 13 | // @homepageURL https://greasyfork.org/zh-CN/scripts/484960-codeforces-match-enhancer 14 | // @supportURL https://github.com/dianhsu/cf-code/issues 15 | // @description auto insert problem id and language in match. 16 | // ==/UserScript== 17 | 18 | $(function () { 19 | 'use strict'; 20 | // get problem id from referrer url. 21 | const re = new RegExp("^https://[0-9a-z]+.codeforces.com/contest/[0-9]+/problem/([0-9a-zA-Z]+)$"); 22 | if (re.test(document.referrer)) { 23 | let arr = re.exec(document.referrer); 24 | document.getElementById("problemIndex").value = arr[1]; 25 | } else { 26 | console.debug("No valid referrer found.") 27 | } 28 | 29 | // load language from local storage and update selector. 30 | let lid = localStorage.getItem("programTypeId"); 31 | document.getElementById("programTypeId").value = lid; 32 | // add event listener to watch selector changes. 33 | document.getElementById("programTypeId").addEventListener('change', function() { 34 | console.log('You selected: ', this.value); 35 | localStorage.setItem("programTypeId", this.value); 36 | }); 37 | }); 38 | 39 | -------------------------------------------------------------------------------- /script.user.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name GYM code view - codeforces.com 3 | // @namespace Violentmonkey Scripts 4 | // @match https://codeforces.com/gym/*/status 5 | // @match https://codeforces.com/submissions/* 6 | // @match https://codeforces.ml/gym/*/status 7 | // @match https://codeforces.ml/submissions/* 8 | // @match https://codeforc.es/gym/*/status 9 | // @match https://codeforc.es/submissions/* 10 | // @grant MIT 11 | // @version 1.5 12 | // @author dianhsu 13 | // @run-at document-idle 14 | // @downloadURL https://raw.githubusercontent.com/dianhsu/cf-code/main/script.user.js 15 | // @homepageURL https://greasyfork.org/zh-CN/scripts/446066-gym-code-view-codeforces-com 16 | // @supportURL https://github.com/dianhsu/cf-code/issues 17 | // @description 在没有登录或者没有开启Coach模式的时候查看Codeforces GYM的代码 18 | // ==/UserScript== 19 | 20 | $(function () { 21 | 'use strict'; 22 | let $tbody = $('table.status-frame-datatable>tbody'); 23 | let tr = $tbody.find('tr'); 24 | let reg = /\d+/g; 25 | for (let i = 1; i < tr.length; ++i) { 26 | let td = $(tr[i]).find('td'); 27 | let submissionId = tr[i].dataset.submissionId; 28 | let cell = $(td[0]).find('span.hiddenSource'); 29 | let problem = $(td[3]).children("a").get(0).getAttribute('href'); 30 | let contestId = problem.match(reg); 31 | if (cell.length > 0) { 32 | let item = document.createElement("a"); 33 | item.href = `https://cf.dianhsu.com/gym/${contestId}/submission/${submissionId}?version=${GM_info.script.version}`; 34 | item.text = `${submissionId}`; 35 | item.target = '_blank'; 36 | cell.after(item); 37 | cell.remove(); 38 | } 39 | } 40 | }); 41 | --------------------------------------------------------------------------------