forked from Shripe/BeamExtended
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbex.js
More file actions
674 lines (591 loc) · 27 KB
/
bex.js
File metadata and controls
674 lines (591 loc) · 27 KB
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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
/** @license
* Copyright (c) 2015 BExDevelopmentTeam
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without limitation of the rights to use, copy, modify, merge,
* and/or publish copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice, any copyright notices herein, and this permission
* notice shall be included in all copies or substantial portions of the Software,
* the Software, or portions of the Software, may not be sold for profit, and the
* Software may not be distributed nor sub-licensed without explicit permission
* from the copyright owner.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Should any questions arise concerning your usage of this Software, or to
* request permission to distribute this Software, please contact the copyright
* holder at contact@exudev.ca or by creating an issue here - https://github.com/ExuDev/BeamExtended/issues
*
* ---------------------------------
*
* Unofficial TLDR:
* Free to modify for personal use
* Need permission to distribute the code
* Can't sell addon or features of the addon
*/
var BeamExtendedInstance;
if (typeof BeamExtendedInstance != 'undefined') {
BeamExtendedInstance.close();
}
BeamExtended = function() {
var VERSION = '1.1.1';
var COMMAND = ':'; // What is before a command?
var twitchEmoteTemplate = '';
var twitchEmotes = [];
var customEmoteTemplate = {
global: '',
channel: ''
};
var customEmotes = [];
var customChannelEmotes = [];
var roles = {};
var colors = {};
var colorWheel = [
"#FF0000",
"#0000FF",
"#008000",
"#B22222",
"#FF7F50",
"#9ACD32",
"#FF4500",
"#2E8B57",
"#DAA520",
"#D2691E",
"#5F9EA0",
"#1E90FF",
"#FF69B4",
"#8A2BE2",
"#00FF7F"
];
var secondColors = {};
var triggeredAlerts = [];
var tssnCrew = ['mindlesspuppetz', 'siggy', 'blackhawk120', 'ziteseve', 'squeaker', 'akujitube', 'artdude543', 'lilmac21', 'icanhascookie69', 'cadillac_don'];
var timeoutAlertChecker;
var timeoutColorGetter;
var styleChannel = 'style';
var pathname = window.location.pathname;
var channel = pathname.toLowerCase().replace("/", "");
function GetStylesheet() {
if (bexoptions.bexbadges === true) {
return 'bexBadgesStyle';
} else if (bexoptions.twitchbadges === true) {
return 'bexTwitchBadgesStyle';
} else {
return 'bexStyle';
}
}
styleChannel = GetStylesheet();
$('head').append('<link rel="stylesheet" href="https://exudev.ca/BeX/Dependencies/qtip.css" type="text/css" />');
setInterval(function() {
var bexBadgesLoaded = $("link[href='https://exudev.ca/BeX/StyleSheets/bexBadgesStyle.css?']").length > 0;
var twitchBadgesLoaded = $("link[href='https://exudev.ca/BeX/StyleSheets/bexTwitchBadgesStyle.css?']").length > 0;
if (bexoptions.bexbadges === true && styleChannel != 'bexBadgesStyle' && !bexBadgesLoaded) {
styleChannel = GetStylesheet();
$cssLink.attr('href', 'https://exudev.ca/BeX/StyleSheets/' + styleChannel + '.css?');
} else if (bexoptions.bexbadges === false && styleChannel == 'bexBadgesStyle' && bexBadgesLoaded) {
styleChannel = GetStylesheet();
$cssLink.attr('href', 'https://exudev.ca/BeX/StyleSheets/' + styleChannel + '.css?');
} else if (bexoptions.twitchbadges === true && styleChannel != 'bexTwitchBadgesStyle' && !twitchBadgesLoaded) {
styleChannel = GetStylesheet();
$cssLink.attr('href', 'https://exudev.ca/BeX/StyleSheets/' + styleChannel + '.css?');
} else if (bexoptions.twitchbadges === false && styleChannel == 'bexTwitchBadgesStyle' && twitchBadgesLoaded) {
styleChannel = GetStylesheet();
$cssLink.attr('href', 'https://exudev.ca/BeX/StyleSheets/' + styleChannel + '.css?');
}
}, 1000);
setInterval(function() {
var isSplitChatLoaded = $("link[href='https://exudev.ca/BeX/StyleSheets/splitchat.css']").length > 0;
if (bexoptions.splitchat === true && !isSplitChatLoaded) {
$('head').append('<link rel="stylesheet" href="https://exudev.ca/BeX/StyleSheets/splitchat.css" type="text/css" />');
} else if (bexoptions.splitchat === false && isSplitChatLoaded) {
$('link[rel=stylesheet][href~="https://exudev.ca/BeX/StyleSheets/splitchat.css"]').remove();
}
}, 1000);
var username = '';
var Utils = {
proxifyImage: function(url) {
if (Utils.startsWithIgnoreCase(url, 'http://')) {
return 'https://api.plugCubed.net/proxy/' + url;
}
return url;
},
getBaseURL: function(url) {
return url.indexOf('#') > -1 ? url.substr(0, url.indexOf('#')) : (url.indexOf('?') > -1 ? url.substr(0, url.indexOf('?')) : url);
},
startsWith: function(a, b) {
if (typeof a === 'string') {
if (typeof b === 'string' && a.length >= b.length) {
return a.indexOf(b) === 0;
} else if ($.isArray(b)) {
for (var c in b) {
if (!b.hasOwnProperty(c)) continue;
var d = b[c];
if (typeof d === 'string' && Utils.startsWith(a, d)) {
return true;
}
}
}
}
return false;
},
startsWithIgnoreCase: function(a, b) {
if (typeof a === 'string') {
if (typeof b === 'string' && a.length >= b.length) {
return Utils.startsWith(a.toLowerCase(), b.toLowerCase());
} else if ($.isArray(b)) {
for (var c in b) {
if (!b.hasOwnProperty(c)) continue;
var d = b[c];
if (typeof d === 'string' && Utils.startsWithIgnoreCase(a, d)) {
return true;
}
}
}
}
return false;
},
endsWith: function(a, b) {
if (typeof a === 'string') {
if (typeof b === 'string' && a.length >= b.length) {
return a.lastIndexOf(b) === a.length - b.length;
} else if ($.isArray(b)) {
for (var c in b) {
if (!b.hasOwnProperty(c)) continue;
var d = b[c];
if (typeof d === 'string' && Utils.endsWith(a, d)) {
return true;
}
}
}
}
return false;
},
endsWithIgnoreCase: function(a, b) {
if (typeof a === 'string') {
if (typeof b === 'string' && a.length >= b.length) {
return Utils.endsWith(a.toLowerCase(), b.toLowerCase());
} else if ($.isArray(b)) {
for (var c in b) {
if (!b.hasOwnProperty(c)) continue;
var d = b[c];
if (typeof d === 'string' && Utils.endsWithIgnoreCase(a, d)) {
return true;
}
}
}
}
return false;
}
};
//region Loading data
$.getJSON('https://beam.pro/api/v1/users/current', function(data) {
if (data.username !== null) {
username = data.username.toLowerCase();
}
});
//region Roles
$.getJSON('https://exudev.ca/BeX/config.json?' + Math.random(), function(data) {
roles = data;
});
//endregion
// This is a cookie loader for the GlobalUsernames - Which makes every user on beam have a color
// It is currenlty not working
// document.cookie.split(';').forEach(function(part) {
// if (part.trim().indexOf('BeXColors') === 0) {
// secondColors = JSON.parse(part.split('=')[1].trim());
// }
// })
//region Chat Colors
$.getJSON('https://exudev.ca/BeX/UsernameColors.json', function(data) {
colors = data;
});
//endregion
//region Emotes
$.getJSON('https://exudev.ca/BeX/emotes/_index.json?' + Math.random(),
/**
* @param {{template: String, emotes: Object}} data
*/
function(data) {
customEmoteTemplate = data.template;
customEmotes = data.emotes;
});
//endregion
//region Twitch Emotes
$.getJSON('https://api.plugcubed.net/twitchemotes',
/**
* @param {{
* template: {
* small: String
* },
* emotes: {
* image_id: Number
* }[]
* }} data
*/
function(data) {
twitchEmoteTemplate = data.template.small;
twitchEmotes = [];
for (var i in data.emotes) {
if (!data.emotes.hasOwnProperty(i)) continue;
twitchEmotes.push({
emote: i,
image_id: data.emotes[i].image_id
});
}
});
//endregion
//region Channel Emotes
function onCustomChannelEmotesLoaded(emotes) {
if (emotes !== null) {
customChannelEmotes = emotes;
if (channel == 'exuviax') {
$messages.append(
$('<div>')
.addClass('message')
.attr('data-role', 'ExuMessage').append(
$('<div>')
.addClass('message-body')
.html('Hey, I help create/maintain <a href="https://github.com/ExuDev/BeamExtended" target="_blank">Beam Extended</a> v' + VERSION + '!<br> To see all my channel emotes and bot commands, go <a href="http://beamalerts.com/bex/exuviax" target="_blank"> here</a>')
)
);
$(".nano").nanoScroller({
scroll: 'bottom'
});
} else {
var $message = $('<div>')
.addClass('message-body')
.html('<a href="https://github.com/ExuDev/BeamExtended" target="_blank">Beam Extended loaded</a> v' + VERSION + '<br><strong>This channel is using custom emotes!</strong><br> The emotes are: ');
for (var i in emotes) {
if (!emotes.hasOwnProperty(i)) continue;
var emote = emotes[i];
$message.append($('<img title="' + emote.emote + '">').addClass('exu-emote').attr('src', customEmoteTemplate.channel.split('{image_pack}').join(emote.image_pack || channel).split('{image_id}').join(emote.image_id).split('{image_ext}').join(emote.image_ext || 'png')).data('emote', $('<span>').html(emote.emote).text()));
}
$messages.append(
$('<div>')
.addClass('message')
.attr('data-role', 'ExuMessage').append(
$message
)
);
$(".nano").nanoScroller({
scroll: 'bottom'
});
}
} else {
$messages.append(
$('<div>')
.addClass('message')
.attr('data-role', 'ExuMessage').append(
$('<div>')
.addClass('message-body')
.html('<a href="https://github.com/ExuDev/BeamExtended" target="_blank">Beam Extended loaded</a> v' + VERSION + '<br> Request custom emotes for your channel <a href=\"http://beamalerts.com/bex/\" target=\"_blank\"> here</a>')
)
);
$(".nano").nanoScroller({
scroll: 'bottom'
});
}
}
$.getJSON('https://exudev.ca/BeX/emotes/' + channel + '/_index.json?' + Math.random())
.done(function(emotes) {
onCustomChannelEmotesLoaded(emotes);
})
.fail(function() {
onCustomChannelEmotesLoaded(null);
});
//endregion
//endregion
var $cssLink = $('<link rel="stylesheet" type="text/css" href="https://exudev.ca/BeX/StyleSheets/' + styleChannel + '.css?">');
$('head').append($cssLink);
function overrideMessageBody($messageBody) {
if ($messageBody.data('overridden') == null) {
// Replace image links with images
if (bexoptions.linkimages === true) {
$messageBody.find('a').each(function() {
if (Utils.endsWithIgnoreCase(Utils.getBaseURL(this.href), ['.gif', '.jpg', '.jpeg', '.png', '.rif', '.tiff', '.bmp'])) {
var original = $('<div>').append($(this).clone()).html();
var $imgContainer = $('<div>').addClass('imgContainer');
$(this).replaceWith($imgContainer);
$imgContainer.append($('<img>').attr('src', Utils.proxifyImage(this.href)));
$imgContainer.append($('<a>').addClass('open btn').text('Open').attr({
target: '_blank',
href: this.href
})).append($('<div>').addClass('remove btn').text('Remove').click(function() {
$(this).text('Are you sure?').off('click').click(function() {
$imgContainer.replaceWith($('<div>').append(original));
});
}));
}
});
}
var messageBody = ' ' + $messageBody.html() + ' ';
var oldMessageBody = messageBody;
var emote, temp, hasEmotes = false;
// Replace Twitch Emotes (Global)
if (bexoptions.twitchemotes === true) {
for (var i in twitchEmotes) {
if (!twitchEmotes.hasOwnProperty(i)) continue;
emote = twitchEmotes[i];
if (messageBody.indexOf(' ' + emote.emote + ' ') > -1 || messageBody.indexOf(':' + emote.emote + ':') > -1) {
hasEmotes = true;
temp = $('<div>').append($('<img bex-tooltip="' + emote.emote + '">').addClass('exu-emote').attr('src', twitchEmoteTemplate.split('{image_id}').join(emote.image_id)).data('emote', $('<span>').html(emote.emote).text()));
messageBody = messageBody.split(' ' + emote.emote + ' ').join(' ' + temp.html() + ' ');
messageBody = messageBody.split(':' + emote.emote + ':').join(temp.html());
}
}
}
// Replace Custom Emotes (Global)
for (i in customEmotes) {
if (!customEmotes.hasOwnProperty(i)) continue;
emote = customEmotes[i];
if (messageBody.indexOf(' ' + emote.emote + ' ') > -1 || messageBody.indexOf(':' + emote.emote + ':') > -1) {
hasEmotes = true;
temp = $('<div>').append($('<img bex-tooltip="' + emote.emote + '">').addClass('exu-emote').attr('src', customEmoteTemplate.global.split('{image_id}').join(emote.image_id).split('{image_ext}').join(emote.image_ext || 'png')).data('emote', $('<span>').html(emote.emote).text()));
messageBody = messageBody.split(' ' + emote.emote + ' ').join(' ' + temp.html() + ' ');
messageBody = messageBody.split(':' + emote.emote + ':').join(temp.html());
}
}
// Replace Custom Emotes (Channel)
for (i in customChannelEmotes) {
if (!customChannelEmotes.hasOwnProperty(i)) continue;
emote = customChannelEmotes[i];
if (messageBody.indexOf(' ' + emote.emote + ' ') > -1 || messageBody.indexOf(':' + emote.emote + ':') > -1) {
hasEmotes = true;
temp = $('<div>').append($('<img bex-tooltip="' + emote.emote + '">').addClass('exu-emote').attr('src', customEmoteTemplate.channel.split('{image_pack}').join(emote.image_pack || channel).split('{image_id}').join(emote.image_id).split('{image_ext}').join(emote.image_ext || 'png')).data('emote', $('<span>').html(emote.emote).text()));
messageBody = messageBody.split(' ' + emote.emote + ' ').join(' ' + temp.html() + ' ');
messageBody = messageBody.split(':' + emote.emote + ':').join(temp.html());
}
}
if (oldMessageBody != messageBody) {
$messageBody.html(messageBody.substr(1, messageBody.length - 1));
if (hasEmotes) {
$messageBody.find('[bex-tooltip!=""]').qtip({ // Grab all elements with a non-blank data-tooltip attr.
style: { classes: 'qtip' },
content: {
attr: 'bex-tooltip' // Tell qTip2 to look inside this attr for its content
}
});
}
}
$messageBody.data('overridden', true);
}
}
function argsToString(args) {
var string = "";
if (args instanceof Array) {
if (args.length > 1) {
var iteration = 0,
delim = "";
for (var x = 0; x < args.length; x++) {
if (iteration === 0) {
iteration = 1;
continue;
}
string += delim + args[x];
delim = " ";
}
}
}
return string;
}
$('textarea[ng-model="message.content"]').on("keyup", function(e) {
var code = e.keyCode || e.which;
if (code == '32') // 9 = TAB
{
var string = $(this).val();
var msgSplit = string.split(" ");
for (var x = 0; x < msgSplit.length; x++) { // Loop through words, to support commands mid-sentence.
if (msgSplit[x].charAt(0) == COMMAND) { // Check first letter is command
switch (msgSplit[x].substring(1)) { // Remove the command executor
case "version":
$(this).val($(this).val().replace(COMMAND + "version", "BEx :: Beam Extended Version " + VERSION + "!")); // Just replace the command.
break;
case "link":
$(this).val($(this).val().replace(COMMAND + "link", "BEx :: You can grab Beam Extended from https://github.com/ExuDev/BeamExtended "));
break;
}
}
}
}
});
function createSettingsPage() {
var opts = $("chat-options"); // Get the div
var parent = opts.find("div section"); // Find the section
if (parent !== null) {
// Add the navigation element for our page
var nav = parent.find(".chat-dialog-menu ul");
nav.find("li").attr("data-apage", "0"); // Add them to my logic
nav.append('<li class="" data-apage="Bex"><a href="#">Bex Settings</a></li>');
}
}
// Selector is a bit annoying, but I can't see a better more reliable one to use.
$(".message-actions .icon-equalizer").click(function() {
createSettingsPage();
});
//$("chat-options").on("click", "input[data-bex]", function() {
// // TEMPORARY FOR TESTING PURPOSES
// console.log("Toggle State of: " + $(this).data("bex"));
//});
$("chat-options").on("click", "li[data-apage]", function() {
var num = $(this).data("apage");
$(this).parent().find("li").removeClass("active");
$(this).addClass("active");
var section = $(this).parent().parent().parent();
// If our page doesn't exist, then re-add it.
// We do this because the Beam system resets the syntax when their pages change.
if ($(".chat-dialog-menu-page.bexobj").length === 0) {
var ourPage = '<div class="chat-dialog-menu-page ng-scope bexobj" data-bpage="Bex">' +
'<table class="table">' +
'<tbody>' +
'<tr>' +
'<td class="col-xs-6"><label>Twitch Emotes</label></td>' +
'<td><label class="checkbox-fancy"><input type="checkbox" data-bex="twitchemotes" class="ng-pristine ng-untouched ng-valid"></label></td>' +
'</tr>' +
'<tr>' +
'<td class="col-xs-6"><label>Username Colors</label></td>' +
'<td><label class="checkbox-fancy"><input type="checkbox" data-bex="usercolors" class="ng-pristine ng-untouched ng-valid"></label></td>' +
'</tr>' +
'<tr>' +
'<td class="col-xs-6"><label>Use BEx Badges</label></td>' +
'<td><label class="checkbox-fancy"><input type="checkbox" data-bex="bexbadges" class="ng-pristine ng-untouched ng-valid"></label></td>' +
'</tr>' +
'<tr>' +
'<td class="col-xs-6"><label>Use Twitch Badges</label></td>' +
'<td><label class="checkbox-fancy"><input type="checkbox" data-bex="twitchbadges" class="ng-pristine ng-untouched ng-valid"></label></td>' +
'</tr>' +
'<tr>' +
'<td class="col-xs-6"><label>Chat Images</label></td>' +
'<td><label class="checkbox-fancy"><input type="checkbox" data-bex="linkimages" class="ng-pristine ng-untouched ng-valid"></label></td>' +
'</tr>' +
'<tr>' +
'<td class="col-xs-6"><label>SplitChat</label></td>' +
'<td><label class="checkbox-fancy"><input type="checkbox" data-bex="splitchat" class="ng-pristine ng-untouched ng-valid"></label></td>' +
'</tr>' +
'</tbody>' +
'</table>' +
'</div>';
section.find(".chat-dialog-menu-page").after(ourPage);
for (opt in bexoptions) {
$('.chat-dialog-menu-page.bexobj input[data-bex="' + opt + '"]').prop("checked", bexoptions[opt]);
}
}
if (num == "Bex") {
section.find(".chat-dialog-menu-page").hide();
section.find('.chat-dialog-menu-page.bexobj').show();
} else {
section.find(".chat-dialog-menu-page").show();
section.find('.chat-dialog-menu-page.bexobj').hide();
}
});
function onChatReceived(event) {
var $this = $(event.target);
var messageAuthor = $this.find('.message-author').text().toLowerCase();
var messageRole = $this.attr('data-role');
if (messageAuthor === null || messageRole === null) {
return;
}
var i;
// Check for special roles
for (i in roles) {
if (!roles.hasOwnProperty(i)) continue;
if (roles[i].indexOf(messageAuthor) > -1) {
messageRole += ' ' + i;
}
}
$this.attr('data-role', messageRole);
// User Colors
if (bexoptions.usercolors === true) {
if (colors[messageAuthor] !== null) {
$this.find('.message-author').css('color', colors[messageAuthor]);
} else if (secondColors[messageAuthor] !== null) {
if (bexoptions.globalcolors === true) {
$this.find('.message-author').css('color', secondColors[messageAuthor]);
}
} else {
if (bexoptions.globalcolors === true) {
var randomPicker = Math.floor(Math.random() * 16);
secondColors[messageAuthor] = colorWheel[randomPicker];
$this.find('.message-author').css('color', secondColors[messageAuthor]);
// Here is more of the cookie loader, which is still not working.
// document.cookie['BeXColors'] = JSON.stringify(secondColors);
}
}
}
overrideMessageBody($this.find('.message-body'));
if (messageAuthor == username) {
$this.on('DOMSubtreeModified', onMessageOverridden);
}
}
function onMessageOverridden(event) {
var $this = $(event.target);
if ($this.hasClass('message-body')) {
setTimeout(function() {
$this.off('DOMSubtreeModified');
}, 500);
$(event.target).data('overridden', null);
overrideMessageBody($this);
}
}
var $messages = $('.messages').find('.nano-content');
$messages.on('DOMNodeInserted', onChatReceived);
console.log('Loaded BeamExtended v' + VERSION);
function checkForAlerts() {
$.getJSON('https://exudev.ca/BeX/alert.json', function(systemAlert) {
for (var i in systemAlert) {
if (!systemAlert.hasOwnProperty(i)) continue;
if (triggeredAlerts.indexOf(systemAlert[i]) > -1) continue;
$messages.append(
$('<div>')
.addClass('message')
.attr('data-role', 'ExuMessage').append(
$('<div>')
.addClass('message-body')
.html('<b>Beam Extended Alert</b><br>' + systemAlert[i])
));
triggeredAlerts.push(systemAlert[i]);
}
});
timeoutAlertChecker = setTimeout(function() {
checkForAlerts();
}, 6e4);
}
checkForAlerts();
this.close = function() {
$messages.off('DOMNodeInserted', onChatReceived);
$cssLink.remove();
clearTimeout(timeoutAlertChecker);
clearTimeout(timeoutColorGetter);
BeamExtendedInstance = undefined;
};
return this;
};
(function() {
function checker() {
if (typeof jQuery !== 'undefined' && $('.messages').length > 0) {
if ($.fn.qtip == null) {
$.getScript('https://mradder.com/ss/jquery.qtip.min.js', function() {
load();
});
return;
}
load();
} else {
setTimeout(function() {
checker();
}, 100);
}
}
function load() {
BeamExtendedInstance = new BeamExtended();
}
checker();
})();