-
Notifications
You must be signed in to change notification settings - Fork 1
/
kill.js
226 lines (191 loc) · 7.34 KB
/
kill.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
// var name = 'webmasteradi';
var name;
var prob_name = [];
chrome.runtime.sendMessage({
method: 'GET',
action: 'xhttp',
usern: name,
// username: 'webmasteradi',
}, function(responseText) {
// console.log(responseText);
console.log("true");
flg = checkResponse(responseText);
if(flg) {
list = parseData((responseText));
console.log(list.length);
console.log("flg ",flg);
}
else {
// bad response , boat down
}
});
function parseData(text) {
var obj = JSON.parse(text);
// console.log(obj);
console.log("len "+obj.result.length);
var ok_set = [];
var no_set = [];
// window.alert(2);
for(i=0,len =obj.result.length; i<len;i++) {
var p_id = obj.result[i].problem.contestId+ obj.result[i].problem.index;
var status = obj.result[i].verdict;
prob_name[p_id] = obj.result[i].problem.name;
if(status == "OK") {
ok_set[p_id] = true;
}
else {
// console.log(p_id+" NO ");
no_set[p_id] = true;
}
}
var x;
for(x in ok_set) {
if(no_set[x]) {
delete no_set[x];
}
}
var list =[];
var j=0;
for(x in no_set) {
console.log(x+" check ");
list[j] = x;
j++;
// console.log("check ");
}
console.log(list[0]+" hi ");
return list;
}
function checkResponse(text) {
var obj = JSON.parse(text);
// console.log(obj);
console.log("valid : "+obj.status);
if(obj.status == "OK") {
return true;
}
else {
return false;
}
}
function blockAndDisplay() {
var feed = $('[id^=topnews_main_stream], [id^=mostrecent_main_stream], [id^=pagelet_home_stream]');
var message = $('#distracted');
var message2 = $('#dis');
if (feed.length == 0) {
message.remove();
} else if (message.length == 0) {
feed.children().remove();
var size
if(typeof list == 'undefined') {
// size =-1;
console.log("waiting")
// for(i=0;i<100000;i++);
}
else {
size = list.length;
}
if(size > 0) {
var str = "These problems\nneed to be solved";
var li = str.link("http://codeforces.com/contest/478/problem/C");
message = $('<h1>')
.attr('id', 'distracted')
// .val( message.val()+"These problems\nneed to be solved")
// .attr("href","http://codeforces.com/contest/478/problem/C")
// .attr("target",'_blank')
.text("These problems\n need to be solved")
// .href("http://codeforces.com/contest/478/problem/C")
.css('font-size', '30px')
.css('font-family', "'Helvetica Neue', Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif")
.css('position', 'relative')
.css('top', '75px');
// .href("http://codeforces.com/contest/574/problem/B");
feed.append(message);
// feed.append(li);
// $('[data-location=maincolumn]').append(message);
for(var i=0;i<size;i++) {
var len = list[i].length;
// console.log(prob_name[list[i]]);
var contestNo = (list[i].substring(0,len-1));
if(contestNo > 9999) {
// console.log("gym",contestNo);
message = $('<a>')
.attr('id', 'distracted')
.text(list[i]+"\t "+prob_name[list[i]]+"\n ")
// .text("Codeforces!!"+list[i].slice(-1)+list[i].substring(0,len-1))
.attr("href","http://codeforces.com/problemset/gymProblem/"+list[i].substring(0,len-1)+"/"+list[i].slice(-1))
.attr("target",'_blank')
.css('font-size', '25px')
.css('font-family', "'Helvetica Neue', Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif")
.css('position', 'relative')
.css('top', '75px');
newline = $('<br>')
.attr('id', 'distracted');
}
else {
// console.log("nope",contestNo);
message = $('<a>')
.attr('id', 'distracted')
.text(list[i]+"\t "+prob_name[list[i]]+"\n ")
// .text("Codeforces!!"+list[i].slice(-1)+list[i].substring(0,len-1))
.attr("href","http://codeforces.com/contest/"+list[i].substring(0,len-1)+"/problem/"+list[i].slice(-1))
.attr("target",'_blank')
.css('font-size', '25px')
.css('font-family', "'Helvetica Neue', Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif")
.css('position', 'relative')
.css('top', '75px');
newline = $('<br>')
.attr('id', 'distracted');
}
feed.append(message);
feed.append(newline);
}
}
// else if(size ==-1) {
// message = $('<h1>')
// .attr('id', 'distracted')
// .text("SORRY!! OUR BOT FAILED TO SERVE THE QUESTIONS :(")
// .css('font-size', '30px')
// .css('font-family', "'Helvetica Neue', Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif")
// .css('position', 'relative')
// .css('top', '75px');
// }
else {
if(!flg) {
message = $('<h1>')
.attr('id', 'distracted')
.text("SORRY!! OUR BOT FAILED TO SERVE THE QUESTIONS :(")
.css('font-size', '30px')
.css('font-family', "'Helvetica Neue', Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif")
.css('position', 'relative')
.css('top', '75px');
feed.append(message);
}
else {
message = $('<h1>')
.attr('id', 'distracted')
.text("Great going!! You don't have any pending problems :)")
.css('font-size', '30px')
.css('font-family', "'Helvetica Neue', Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif")
.css('position', 'relative')
.css('top', '75px');
// $('[data-location=maincolumn]').append(message);
cf =$('<a>')
.attr('id', 'distracted')
.text("Try out some new ones at Codeforces")
.attr("href","http://codeforces.com/")
.attr("target",'_blank')
.css('font-size', '30px')
.css('font-family', "'Helvetica Neue', Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif")
.css('position', 'relative')
.css('top', '75px');
feed.append(message);
feed.append(cf);
}
}
}
$('.ticker_stream').remove();
$('.ego_column').remove();
// $('#pagelet_games_rhc').remove();
// $('#pagelet_trending_tags_and_topics').remove();
// $('#pagelet_canvas_nav_content').remove();
}
window.setInterval(blockAndDisplay, 100);