-
Notifications
You must be signed in to change notification settings - Fork 0
/
kick.js
218 lines (174 loc) · 6.7 KB
/
kick.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
/*************************************************
2011 Sergey Lubenin [email protected]
2017 Dmitry Vorobiev [email protected]
*************************************************/
var current_pretendent = "";
var collapse_quotes="yes";
var vhosts = [
[
/((http\:\/\/)?(www\.)?youtube\.com\/watch\?v\=)([a-zA-Z0-9\-_]+)(\&.*)?$/i ,
"<iframe title=\"YouTube video player\" width=\"425\" height=\"349\" src=\"https://www.youtube.com/embed/$4\" frameborder=\"0\" allowfullscreen></iframe>"
],
[
/((http\:\/\/)?(www\.)?rutube\.ru\/tracks\/\d+\.html\?v\=)([a-zA-Z0-9\-]+)(\&.*)?$/i ,
"<OBJECT width=\"470\" height=\"353\"><PARAM name=\"movie\" value=\"https://video.rutube.ru/$4\"></PARAM><PARAM name=\"wmode\" value=\"window\"></PARAM><PARAM name=\"allowFullScreen\" value=\"true\"></PARAM><EMBED src=\"https://video.rutube.ru/$4\" type=\"application/x-shockwave-flash\" wmode=\"window\" width=\"470\" height=\"353\" allowFullScreen=\"true\" ></EMBED></OBJECT>"
]
];
$(document).ready(function(){
var messagesRegex = /user\/(\d+)\//gi;
var profileId = $('#navprofile').find("a").attr('href')||"";
if (profileId == "")
{}
else
{
$.get(
profileId,
function(data) {
var ratingRegex = /\[ \+ (\d+) \| (\d+) \- \]/gi;
var ratingVals = ratingRegex.exec(data);
var ratingNumber = ratingVals[1] - ratingVals[2];
chrome.extension.sendMessage({
type: "ratingChanged",
data: {
ratingValue: ratingNumber
}
});
$('#brd-visit').append('<p id="test"><span> Ваш рейтинг: <strong>'+ratingNumber+'</strong></span></p>');
}
)
}
var body = {
"font-family":"Verdana, Helvetica, sans-serif",
}
$("body").css(body);
function insertText(){
var tag = $(this).attr("title");
var messageForm = document.getElementsByName("req_message")[0];
var text = messageForm.value;
messageForm.focus();
if (document.getSelection) {
var start = messageForm.selectionStart;
var end = messageForm.selectionEnd;
if (start-end != 0) {
var selectedText = text.substring(start, end);
text = text.replace(selectedText, "["+tag+"]"+selectedText+"[/"+tag+"]");
messageForm.value = text;
}
else {
text = text.substring(0,start)+"["+tag+"][/"+tag+"]"+text.substring(end,text.length);
messageForm.value = text;
}
}
};
});
chrome.extension.sendRequest({localstorage: "kicked"}, function(response) {
var st = response.kicked.split("=#####=");
$("body").append("<div id='popupp' style='position:absolute;padding:9px;-webkit-border-radius:10px;font-size:12px;background:#EEE;-webkit-box-shadow:0 0 3px 4px #CCC;display:none;z-index:5000;'><a id='to_s' style='color:red' href='javascript:;' >В список!</a><br /><br /><a style='color:green' href='javascript:;' id='from_s'>Реабилитировать</a></div>");
// chrome.storage.local.get({"collapsequotes":"yes"}, function(data) {
// Use data[key]
// collapse_quotes = data["collapsequotes"];
// console.log(collapse_quotes);
// });
$("strong.info-replies").css('left','0px');
$("#to_s").click(function() {
var uy = current_pretendent;
var lst = st;
var lsst = st.join('=#####=');
if ( !in_array(uy,lst) && uy!="" ){
var t =(lsst=="" ? '':lsst+'=#####=')+uy;
lsst = t;
chrome.extension.sendRequest({localstorage: "set",settedValue:lsst},function(response){document.location.reload()});
} else {
alert('Уже в списке!');
}
});
function a_index(arr,fin){
for(var i=0,l=arr.length;i<l;i++){
if (arr[i]==fin) return i;
}
}
$("#from_s").click(function(){
var uy = current_pretendent;
var lst = st;
if (in_array(uy,lst) && uy!=""){
var aj = a_index(lst,uy);
if(aj>=0) delete lst[aj];
chrome.extension.sendRequest({localstorage: "set",settedValue:lst.join('=#####=')},function(response){document.location.reload()});
} else {
alert('Его и так там нет!');
}
});
$("div.posthead").bind("contextmenu",function(event){
var target = (event||window.event);
var x = target.clientX+document.documentElement.scrollLeft+5;
var y = target.clientY+document.documentElement.scrollTop+5;
current_pretendent = $(this).find("span.post-byline").find("a").text()||"";
$("#popupp").css({'left':x+'px','top':y+'px'}).show();
$("div.posthead").click(function(){
var ob = $("#popupp");
if (ob.is(':visible'))
ob.hide("fast");
});
return false});
$("li.username").each(function(){
var text = $(this).text()||"";
if (in_array(text,st) && text!="") {
$(this)
.parents("div.post")
.hide();
}
});
$("div.entry-content").each(function(){
$(this).find("a").each(function(){
var div_parent= $(this).parents("div.entry-content");
if (/http.*\:\/\/coub\.com\/view\//.test($(this).text())) {
var c_url = $(this).text().replace(/http.*\:\/\/coub\.com\/view\//gim,'') || "";
$(this).replaceWith('<iframe src="https://coub.com/embed/' + c_url + '?autoplay=true" allowfullscreen="true" frameborder="0" width="640" height="288"></iframe>');
}
});
});
$("div.quotebox").each(function(){
$(this).find("a").each(function(){
var div_parent= $(this).parents("div.quotebox");
if (/http.*\:\/\/coub\.com\/view\//.test($(this).text())) {
var c_url = $(this).text().replace(/http.*\:\/\/coub\.com\/view\//gim,'') || "";
$(this).replaceWith('<iframe src="https://coub.com/embed/' + c_url + '?autoplay=true" allowfullscreen="true" frameborder="0" width="640" height="288"></iframe>');
}
});
});
$("div.quotebox").each(function(){
var text = $(this).find("cite").text().replace(/\s+пишет\:/gim,'')||"";
if(in_array(text,st) && text!="") $(this).css({'opacity':'0.1'});
});
$("span.item-starter").each(function(){
var text = $(this).find("cite").text()||"";
if(in_array(text,st) && text!="") $(this).parents("div.main-item").css({'opacity':'0.1'});
});
$("td.td3").each(function(){
var text = $(this).find("a").text()||"";
if(in_array(text,st) && text!="") {
$(this)
.parents("tr")
.hide();}
});
});
chrome.extension.sendRequest({localstorage: "cllpsqts"}, function(response) {
if (response.cllpsqts && (response.cllpsqts !== "false") )
{
$("div.quotebox").each(function(){
var oldhtmlquotebox = $(this).html();
$(this).html( "<input type='button' class='hideshow' value='+/-'>"+oldhtmlquotebox );
});
$("blockquote").each(function(){
$(this).hide();
});
$(".hideshow").each(function(){
$(this).click(function(event) {
$(this).parents("div.quotebox").find("blockquote").each(function (){
$(this).toggle("show");
});
$(this).blur();
});
});
}
});