Skip to content

Commit 67c74f2

Browse files
committed
added all submissions tab in problemset
1 parent 556fb1f commit 67c74f2

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"problemset.js"
4949
],
5050
"matches": [
51-
"https://*.codeforces.com/problemset/problem/*"
51+
"https://*.codeforces.com/problemset/problem/*",
52+
"https://*.codeforces.com/contest/*/problem/*"
5253
],
5354
"run_at": "document_idle"
5455
}

src/problemset.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
chrome.storage.sync.get('problemset', function(data){
2+
// if option disabled, return, else inject script
3+
if(!data.problemset){
4+
return;
5+
}
6+
7+
// global page constants
8+
const contestURL = $('#sidebar th a').attr('href'); // '/contest/<no.>'
9+
const probLetter = $('.header > .title').text()[0];
10+
11+
// add all submissions tab to the menu
12+
const tab = $('.second-level-menu-list')[0].lastElementChild;
13+
const allSubmissions = $(tab).clone(true)[0];
14+
const allSubmissionsURL = contestURL + '/status/' + probLetter;
15+
$('a', allSubmissions).text('all submissions');
16+
$('a', allSubmissions).attr('href', allSubmissionsURL);
17+
tab.after(allSubmissions);
18+
19+
// add star favourite problem icon
20+
const starContest = $('#sidebar > div:nth-child(1) > table > tbody > tr:last-child');
21+
$('> td > span > center > span > img', starContest).attr('alt', 'Add contest to favourites');
22+
$('> td > span > center > span > img', starContest).attr('title', 'Add contest to favourites');
23+
24+
const starProblem = $(('<tr><td class="left bottom" colspan="1"><span class="contest-state-regular">Problem: <span id="put"></span></span></td></tr>'));
25+
$(starContest).after(starProblem);
26+
27+
// make selector to get probem-star
28+
const row = probLetter.charCodeAt(0) - 65 + 2;
29+
const selector = "#pageContent > div.datatable > div:nth-child(6) > table > tbody > tr:nth-child("+String(row)+") span:nth-child(2) > span >img"
30+
const url = contestURL + ' ' + selector;
31+
32+
$("#put").load(url, function () {
33+
const star = $('#put')[0].childNodes[0];
34+
35+
});
36+
});

0 commit comments

Comments
 (0)