-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
408 lines (274 loc) · 11 KB
/
index.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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
//iclude jquery js file here
$(document).ready(function(){
var mesgMaskOut="C:\\Users\\Out";
var mesgMaskIn="C:\\Users\\In> ";
function replaceMicWithLink(){
$("div.block-compose").find(".btn-icon").insertAfter("<button onclick='alert(1)'>A</button>");
// $("div.block-compose").find(".btn-icon").hide();
}
function maskTitle(){
$("title").off("DOMSubtreeModified");
$("#favicon").off("DOMAttrModified");
$("title").text("commands Test Window");
$("#favicon").attr("href","https://cdn.sstatic.net/stackoverflow/img/favicon.ico?v=4f32ecc8f43d");
$("title").on("DOMSubtreeModified",maskTitle);
$("#favicon").on("DOMAttrModified",maskTitle);
}
function addCssRule(rule, css) {
css = JSON.stringify(css).replace(/"/g, "").replace(/,/g, ";");
$("<style>").prop("type", "text/css").html(rule + css).appendTo("head");
}
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.attributeName === "class") {
var attributeValue = $(mutation.target).prop(mutation.attributeName);
console.log("Message delivery status changes:", attributeValue);
maskMessages();
}
});
});
function maskMessages(){
// unbinding DOMNodeInserted event to avoid infinite loop
$('.pane-chat-msgs .message-list').off('DOMNodeInserted');
console.info("message list changes");
/**
* chat message box consists of two main parts 1) Actual text 2) meta data of text mesg like delivery status read,delivered,etc.
* vW7d1=> Element with this class represnts entire text box both IN and OUT mesgs.
* type of messsage is detected by css class names say for eaxmple "message-out" and "message-in" represets out message and In messages respectively.
*
* Below structure explains how the message boxes oragnised by whatsapp
*
* messgebox "div.vW7d1"
* |
* |- typeof message "div.message-out" or "div.message-in"
* |
* |-one parent div which holds both text and delivey status "div.Tkt2p"
* |-actual mesg text "span.selectable-text"
* |-delivey status ""
*/
const selectors={
'rootMesg': "div.vW7d1",
'inMesg': "div.message-in",
'outMesg': "div.message-out",
'text': "span.selectable-text",
'deliveryStatus': "span[data-icon='msg-dblcheck-ack']"
};
$(`${selectors.rootMesg}[ismasked!='true']`).each(function(){
if(($(this).find(".message-out").length>0) && ($(this).attr("ismasked")!="true")){
var mesgEle=$(this).find(".message-out .bubble-text .message-text .emojitext");
var mesgMetaEle=$(this).find(".message-out .bubble-text .message-meta .icon");
var readStatus="";
if(mesgMetaEle.hasClass("icon-msg-dblcheck-ack")){
$(this).attr("ismasked","true");
readStatus="\\Read> ";
}else if(mesgMetaEle.hasClass("icon-msg-check")){
readStatus="\\Not Delivered> ";
}else if(mesgMetaEle.hasClass("icon-msg-dblcheck")){
readStatus="\\Delivered> ";
}else{
readStatus="\\unknown state> ";
}
$(this).find(".message-meta").css({"text-indent":"-1000px"});
var mesg=mesgEle.text();
var prelen=mesgEle.attr("mesgPrefixlength");
if(typeof prelen!='undefined'){
mesg=mesg.slice(prelen);
}
var mesgPrefix=mesgMaskOut+readStatus;
mesgEle.attr("mesgPrefixlength",mesgPrefix.length)
mesgEle.text(mesgPrefix+mesg);
//adding listener on delivery status of mesg
try{
observer.observe(mesgMetaEle[0], { attributes: true });
}catch(e){
}
}else if($(this).find(".message-in").length>0){
$(this).attr("ismasked","true");
var inMesgEle=$(this).find(".message-in .bubble-text .message-text .emojitext");
var inMesg=mesgMaskIn+inMesgEle.text();
inMesgEle.text(inMesg);
}
});
$('.pane-chat-msgs .message-list').bind('DOMNodeInserted', maskMessages);
}
function test(){
$(".app-wrapper::after").css({"display":"none"})
$(".app-wrapper, .app-wrapper-main").attr("style", "opacity: 0.3 !important;");
$("#app,.app").attr("style", "background: #000 !important");
$(".pane-body").attr("style", "background: #000 !important");
$("#main").attr("style", "background: #000 !important");
$(".message-list").attr("style", "background:#000 !important");
$("footer").attr("style", "background:#000 !important");
$(".bubble-text").attr("style", "background:#000 !important");
$("div.message-list").attr("style", "background:#000 !important");
//hiding day of the week
$(".message-system-body").attr("style", "background:#000 !important;color:#fff !important");
//message box styles
//pane-chat-msgs
$(".pane-chat-body").attr("style", "background:#ccc !important;");
$(".pane-chat-msgs .message-list .msg").attr("style", "background-color:#000 !important;padding:0px;");
$(".pane-chat-msgs .message-list .message-out").attr("style", "background-color:#000 !important");
$(".message-out .bubble div.message-text").css({"color":"#fff"});
$(".pane-chat-msgs .message-list .message-in").attr("style", "background-color:#000 !important");
$(".message-in .bubble div.message-text").css({"color":"#fff"});
$(".message-in,.message-out").css({"float":"left","max-width":"80%"});
//hiding the contact header
$(".pane-header").hide();
replaceMicWithLink();
//listener fn when mesg sent or receieved
$('.pane-chat-msgs .message-list').bind('DOMNodeInserted', maskMessages);
$("#title").on("DOMSubtreeModified",maskTitle);
$("#favicon").on("DOMAttrModified",maskTitle);
}
const constants ={
'cmdLinePlaceHolder':"C:\\Users\\hkolli.FTDCORP>",
'mesgMaskOut': "C:\\Users\\Out",
'mesgMaskIn': "C:\\Users\\In> ",
'delveryStatuses' : ''
};
function log(msg){
console.log("-----start---"+log.caller.toString()+"-----------");
console.log(msg);
console.log("-------end----"+log.caller.toString()+"--------");
}
function maskInputTextbox(){
$("div._39LWd").before(`<span style='color:#fff'> ${constants.cmdLinePlaceHolder} </span>`);
//changing the place holder of textbox 'Type a message' to 'Enter the npm command'
$("._39LWd").text('Enter the npm command..');
}
//Add ur css classes here ..thess will be added to existing style sheet.
function applyClassesToStyleSheet(){
$("<style type='text/css' id='dynamic' />").appendTo("head");
var styles=`
${ removeMainPageStyles() }
${ hideSideContacts() }
${ hideDPHeader() }
${ removeDefaultMesgStyles() }
${ removeBottomTextBoxStyles() }
${ removeMiddleNotificationStyles() }
/* ==== styles to reomve extra corners in message boxes starts ========*/
.tail-container{
display:none !important;
}
.message-out .tail-container.highlight{
display:none !important;
}
.tail-override-right .tail-container{
display:none !important;
}
/* styles to reomve extra corners in message boxes ends*/
/* ===== util classes =======*/
.none{
display: none !important;
}
`;
$("#dynamic").text(styles);
}
function removeBottomTextBoxStyles(){
maskInputTextbox();
//retun the new styles for input textbox
return `
/*=========bottom textbox styles styles======= */
._3oju3{
background-color:#000 !important;
}
._2bXVy{
background-color:#000 !important;
border-color:#000 !important;
}
._3F6QL{
color:#fff !important;
}
._3F6QL div._39LWd{
left:200px !important;
}
`;
}
//side bar or contacts widget tweaks
function hideSideContacts(){
$("._3q4NP .k1feT").hide();
$("#side").hide();
return `
._3q4NP .k1feT{
display:none;
}
`;
}
//removes default styles for messages
function removeDefaultMesgStyles(){
return `
/* =========out message box styles starts=========*/
.message-out{
background-color:#000 !important;
color:#efefef !important;
}
/* out message box styles ends*/
/* =========in message box styles starts=========*/
.message-in{
background-color:#000 !important;
color:#efefef !important;
}
/* in message box styles ends*/
.message-out, .message-in{
float:left !important;
width:80% !important;
}
//Y9G3K is for quoted mesg styles meaning i.e (reply to sent mesg)
.Y9G3K{
color:#fff !important;
}
`;
}
function removeMainPageStyles(){
return `
/* ======global page background colors styles====*/
.app-wrapper::after{
background: #000 !important
}
`;
}
//removes middle notifications like "1 Unread Message" in the middle of the chat window
function removeMiddleNotificationStyles(){
return `
.vW7d1 ._3rjxZ, ._1mq8g{
display:none;
}
`;
}
//fn to hide contact name,dp header
function hideDPHeader(){
return `
/* =========dp header styles ==========*/
header._3AwwN{
display:none;
}
`;
}
//apply extra styles to IN mesgs
function convertInMesgStyles(){
}
//apply extra styles to OUT mesgs
function convertOutMesgStyles(){
}
//get actual text from chat so that we can apply some masks/styles on it.
function textExtractorFromMesg(){
}
function hideEmjoi(){
}
//detect emoji type like anger,smile
function detectEmojiType(){
}
var checkExist=setInterval(function(){
if(($("header").length>0) && ($("footer").length>0) ){
// hideGlobalPageBgColors();
applyClassesToStyleSheet();
//removeDefaultMesgStyles();
convertInMesgStyles();
convertOutMesgStyles();
test();
maskTitle();
addCssRule("",{});
clearInterval(checkExist);
}
},10000);
});