forked from pndurette/gTTS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
token-script.js
62 lines (54 loc) · 1.86 KB
/
token-script.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
// Token calculating functions found inline on translate.google.com
var cM = function(a) {
return function() {
return a
}
};
var of = "=";
var dM = function(a, b) {
for (var c = 0; c < b.length - 2; c += 3) {
var d = b.charAt(c + 2),
d = d >= t ? d.charCodeAt(0) - 87 : Number(d),
d = b.charAt(c + 1) == Tb ? a >>> d : a << d;
a = b.charAt(c) == Tb ? a + d & 4294967295 : a ^ d
}
return a
};
var eM = null;
var cb = 0;
var k = "";
var Vb = "+-a^+6";
var Ub = "+-3^+b+-f";
var t = "a";
var Tb = "+";
var dd = ".";
fM = function(a) {
var b;
if (null === eM) {
var c = cM(String.fromCharCode(84)); // char 84 is T
b = cM(String.fromCharCode(75)); // char 75 is K
c = [c(), c()];
c[1] = b();
// So basically we're getting window.TKK
eM = Number(window[c.join(b())]) || 0
}
b = eM;
// All this does is convert turn d into the byte values of the utf-8 representation of a
var d = cM(String.fromCharCode(116)),
c = cM(String.fromCharCode(107)),
d = [d(), d()];
d[1] = c();
for (var c = cb + d.join(k) +
of, d = [], e = 0, f = 0; f < a.length; f++) {
var g = a.charCodeAt(f);
128 > g ? d[e++] = g : (2048 > g ? d[e++] = g >> 6 | 192 : (55296 == (g & 64512) && f + 1 < a.length && 56320 == (a.charCodeAt(f + 1) & 64512) ? (g = 65536 + ((g & 1023) << 10) + (a.charCodeAt(++f) & 1023), d[e++] = g >> 18 | 240, d[e++] = g >> 12 & 63 | 128) : d[e++] = g >> 12 | 224, d[e++] = g >> 6 & 63 | 128), d[e++] = g & 63 | 128)
}
// So now utf8(d) == a
a = b || 0;
for (e = 0; e < d.length; e++) a += d[e], a = dM(a, Vb);
a = dM(a, Ub);
0 > a && (a = (a & 2147483647) + 2147483648);
a %= 1E6;
return a.toString() + dd + (a ^ b)
};
console.log(fM("Hello person"));