1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | function encodeUnicode(str) {
|
8 | return String(str).replace(/[^\x09-\x7f\ufeff]/g, function (all) {
|
9 | return '\\u' + (0x10000 + all.charCodeAt()).toString(16).substring(1);
|
10 | });
|
11 | }
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | module.exports = function (content) {
|
19 | if (!content) {
|
20 | return content;
|
21 | }
|
22 | var t = parseInt('10000000', 2);
|
23 | content = encodeUnicode(content).replace(/[^]/g, function (all) {
|
24 | return (t + all.charCodeAt()).toString(2).substring(1).replace(/[^]/g, function (n) {
|
25 | return {
|
26 | 0: '\u200c',
|
27 | 1: '\u200d'
|
28 | }[n];
|
29 | });
|
30 | });
|
31 | return '(function(){}).constructor("' + content + '".replace(/./g,function(a){return{"\u200c":0,"\u200d":1}[a]}).replace(/.{7}/g,function(a){return String.fromCharCode(parseInt(a,2))}))();';
|
32 | }; |
\ | No newline at end of file |