-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmisc.js
88 lines (77 loc) · 2.18 KB
/
misc.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
function mircToHtml(text) {
//control codes
var rex = /\003([0-9]{1,2})[,]?([0-9]{1,2})?([^\003]+)/,
matches, colors;
if (rex.test(text)) {
while (cp = rex.exec(text)) {
if (cp[1] && cp[1].length == 1)
cp[1] = "0" + cp[1];
if (cp[2] && cp[2].length == 1)
{
cp[2] = "0" + cp[2];
var cbg = cp[2];
}
var text = text.replace(cp[0], '<span class="'+(cp[1] ? 'IRCCF' + cp[1] : "") + (cbg ? ' IRCCC' + cbg : "") + '">' + cp[3] + '</span>');
}
}
//bold,italics,underline
var bui = [
[/\002([^\002]+)(\002)?/, ["<b>", "</b>"]],
[/\037([^\037]+)(\037)?/, ["<u>", "</u>"]],
[/\035([^\035]+)(\035)?/, ["<i>", "</i>"]]
];
for (var i = 0; i < bui.length; i++) {
var bc = bui[i][0];
var style = bui[i][1];
if (bc.test(text)) {
while (bmatch = bc.exec(text)) {
var text = text.replace(bmatch[0], style[0] + bmatch[1] + style[1]);
}
}
}
return text;
};
function Escape(string)
{
string = specialEscape(string);
string = mircToHtml(string);
return string;
}
function getElementsByIdRegex(startswith, endswith = null)
{
var arr = [];
var str = '[id^="'+startswith+'"]';
str += endswith ? '[id$="'+endswith+'"]' : '';
Array.from(
document.querySelectorAll('[id^="edit-tid"][id$="-view"]'))
.forEach(function (x) {
arr.push(x);
}
);
return arr;
}
function string_starts_with(string, string2)
{
return string.substring(0, string2.length) == string2;
}
function string_ends_with(string, string2)
{
let len = '-' + string2.length + 1;
return string.substring(len, string2.length) == string2;
}
function IsCtcp(string)
{
if (string_starts_with(string,'\u0001') && string_ends_with(string,'\u0001'))
return true;
return false;
}
function doMiddleBubbble(msg)
{
writeToScreen(
`<div style="color:var(--qtpi-greydient)" class="text-center">
<div class="btn btn-dark rounded">
<i>`+msg+`</i>
</div>
</div>`
);
}