-
Notifications
You must be signed in to change notification settings - Fork 1
/
content2.js
59 lines (50 loc) · 1.66 KB
/
content2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
var url = window.location.href;
url = url.slice(30 + (url[4] == 's' ? 1 : 0), url.length);
var arr = url.split(/[\/\?]/);
arr = [arr[0], arr[2]];
var requestURL = 'https://codeforces.com/api/contest.standings?contestId=' + arr[0] + '&from=1&count=1';
var xhr = new XMLHttpRequest();
xhr.open("GET", requestURL);
xhr.responseType = 'json';
xhr.send();
var rating = null;
function isRus(){
var c = document.cookie.split('; ');
for(var ii = 0; ii < c.length; ii++){
var i = c[ii];
if(i == "nocturne.language=ru") return true;
}
return false;
}
xhr.onload = function() {
var content = xhr.response['result']['problems'];
for (var i = 0; i < content.length; i++) {
if(content[i]['index'] == arr[1]){
rating = content[i]['rating'];
break;
}
}
if(rating != null){
document.getElementById('sidebar').innerHTML += `<div class="roundbox sidebox" style="">
<div class="roundbox-lt"> </div>
<div class="roundbox-rt"> </div>
<div class="caption titled">→ ` + (isRus() ? "Рейтинг задачи" : "Problem rate") + `
<div class="top-links">
</div>
</div>
<div>
<div style="margin:1em;font-size:0.8em;">
<div class="roundbox " style="margin:2px; padding:0 3px 2px 3px; background-color:#f0f0f0; width: 4rem">
<div class="roundbox-lt"> </div>
<div class="roundbox-rt"> </div>
<div class="roundbox-lb"> </div>
<div class="roundbox-rb"> </div>
<span class="tag-box" style="font-size:1.2rem;" title="Сложность">
*`+ rating + `
</span>
</div>
</div>
</div>
</div>`;
}
}