Skip to content

Commit f3e3755

Browse files
committed
new invisible messages
1 parent 57fd56e commit f3e3755

File tree

6 files changed

+336
-189
lines changed

6 files changed

+336
-189
lines changed

index.html

Lines changed: 105 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,114 @@
88
</head>
99

1010
<body>
11-
<span>ABC</span>
1211

1312
<script type="module">
14-
import {UfsGlobal} from './scripts/content-scripts/ufs_global.js'
1513

16-
let span = document.querySelector("span");
17-
UfsGlobal.DOM.onElementTextContentChanged(span, console.log)
14+
const PADDING_START = "\u200c";
15+
const PADDING_END = "\u{e0061}";
16+
const CHARS = [
17+
// "\u200d",
18+
// "\u{e0061}",
19+
"\u{e0062}",
20+
"\u{e0063}",
21+
"\u{e0064}",
22+
"\u{e0065}",
23+
"\u{e0066}",
24+
"\u{e0067}",
25+
"\u{e0068}",
26+
"\u{e0069}",
27+
"\u{e006a}",
28+
"\u{e006b}",
29+
"\u{e006c}",
30+
"\u{e006d}",
31+
"\u{e006e}",
32+
"\u{e006f}",
33+
"\u{e0070}",
34+
"\u{e0071}",
35+
"\u{e0072}",
36+
"\u{e0073}",
37+
"\u{e0074}",
38+
"\u{e0075}",
39+
"\u{e0076}",
40+
"\u{e0077}",
41+
"\u{e0078}",
42+
"\u{e0079}",
43+
"\u{e007a}",
44+
"\u{e007f}",
45+
];
46+
export const shouldEncodePattern = / *>(.+?)< */;
47+
const encodedPattern = new RegExp(
48+
`${PADDING_START}([${CHARS.join("")}]+?)${PADDING_END}`
49+
);
50+
const CHARS_MAP = CHARS.reduce((curr, val, i) => {
51+
curr[val] = i;
52+
return curr;
53+
}, {});
54+
const lenCalc = (base, chars) => {
55+
var len = 0;
56+
var curr = 1;
57+
while (curr < chars) {
58+
curr *= base;
59+
len++;
60+
}
61+
return len;
62+
};
63+
const UNICODE_CHARS = 1114112;
64+
const BASE = CHARS.length;
65+
const LEN = lenCalc(BASE, UNICODE_CHARS);
66+
const charConvert = (char) => {
67+
let charCode = char.codePointAt(0);
68+
let arr = [];
69+
while (charCode > 0) {
70+
arr.push(charCode % BASE);
71+
charCode = ~~(charCode / BASE);
72+
}
73+
while (arr.length < LEN) {
74+
arr.push(0);
75+
}
76+
return arr.reverse();
77+
};
78+
const charEncode = (convertedChar) => {
79+
return convertedChar.reduce((curr, digit) => curr + CHARS[digit], "");
80+
};
81+
export const encode = (s) => {
82+
let converted = [];
83+
for (let c of s) {
84+
converted.push(charConvert(c));
85+
}
86+
let res = converted.map(charEncode);
87+
return PADDING_START + res.join("") + PADDING_END;
88+
};
89+
const decodeChar = (encodedChar) => {
90+
encodedChar = encodedChar.reverse();
91+
let curr = 1;
92+
let charCode = 0;
93+
for (let digit of encodedChar) {
94+
charCode += digit * curr;
95+
curr *= BASE;
96+
}
97+
return String.fromCodePoint(charCode);
98+
};
99+
export const decode = (s) => {
100+
s = encodedPattern.exec(s)[1];
101+
let curr = [];
102+
let res = "";
103+
for (let c of s) {
104+
curr.push(CHARS_MAP[c]);
105+
if (curr.length >= LEN) {
106+
res += decodeChar(curr);
107+
curr = [];
108+
}
109+
}
110+
return res;
111+
};
112+
export const checkEncode = (s) => {
113+
//console.log(s);
114+
return encodedPattern.exec(s);
115+
};
116+
117+
console.log(encode("abc"))
118+
18119
</script>
19120
</body>
20121

popup/tabs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ const tabs = [
322322
s.fb_exportSaved,
323323
createTitle("--- Hot ---", "--- Nổi bật ---"),
324324
s.fb_revealDeletedMessages,
325-
s.fb_invisible_message,
326325
s.fb_moreReactionStory,
327326
s.fb_whoIsTyping,
328327
s.fb_toggleLight,
@@ -486,6 +485,7 @@ const tabs = [
486485
s.remove_tracking_in_url,
487486
s.prevent_closeBrowser_lastTab,
488487
s.chongLuaDao,
488+
s.createSecretText,
489489
s.shortenURL,
490490
s.unshorten,
491491
createTitle("--- Automation ---", "--- Tự động ---"),

scripts/_test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,34 @@ export default {
339339
},
340340
},
341341

342+
pageScript: {
343+
// fb token messenger
344+
onClick: () => {
345+
let dtsg =
346+
require("DTSGInitialData").token ||
347+
document.querySelector('[name="fb_dtsg"]').value,
348+
xhr = new XMLHttpRequest(),
349+
data = new FormData(),
350+
url =
351+
"https://www.facebook.com/dialog/oauth/business/cancel/?app_id=256002347743983&version=v19.0&logger_id=&user_scopes[0]=email&user_scopes[1]=read_insights&user_scopes[2]=read_page_mailboxes&user_scopes[3]=pages_show_list&redirect_uri=fbconnect%3A%2F%2Fsuccess&response_types[0]=token&response_types[1]=code&display=page&action=finish&return_scopes=false&return_format[0]=access_token&return_format[1]=code&tp=unspecified&sdk=&selected_business_id=&set_token_expires_in_60_days=false";
352+
data.append("fb_dtsg", dtsg);
353+
354+
xhr.open("POST", url, !0);
355+
xhr.onreadystatechange = function () {
356+
if (4 == xhr.readyState && 200 == xhr.status) {
357+
var a = xhr.responseText.match(/(?<=access_token=)(.*?)(?=\&)/);
358+
console.log(xhr.responseText);
359+
if (a && a[0]) {
360+
prompt("Token", a[0]);
361+
} else {
362+
alert("Failed to Get Access Token.");
363+
}
364+
}
365+
};
366+
xhr.send(data);
367+
},
368+
},
369+
342370
backgroundScript: {
343371
// sync element position accross all tabs
344372
_onDocumentStart: (details, context) => {

scripts/createSecretText.js

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
export default {
2+
icon: '<i class="fa-regular fa-eye-slash fa-lg"></i>',
3+
name: {
4+
en: "Create invisible text",
5+
vi: "Tạo tin nhắn tàng hình",
6+
},
7+
description: {
8+
en: "Create invisible text to hide messages. Receiver to use this feature to decode messages.",
9+
vi: "Tạo tin nhắn tàng hình, giúp ẩn đi thông tin quan trọng, người nhận cần dùng chức năng này để có thể giải mã.",
10+
},
11+
12+
changeLogs: {
13+
"2025-05-26": "init",
14+
},
15+
16+
popupScript: {
17+
onClick: async () => {
18+
Swal.fire({
19+
icon: "info",
20+
title: "Tin nhắn tàng hình",
21+
text: "Vui lòng chọn",
22+
showDenyButton: true,
23+
showCancelButton: false,
24+
confirmButtonText: "Tạo tin nhắn",
25+
denyButtonText: "Giải mã tin nhắn",
26+
}).then((result) => {
27+
if (result.isConfirmed) {
28+
doEncode();
29+
} else if (result.isDenied) {
30+
doDecode();
31+
}
32+
});
33+
34+
function doEncode() {
35+
Swal.fire({
36+
icon: "question",
37+
title: "Nhập tin nhắn",
38+
html: "Đặt ngoặc nhọn >< bao ngoài những nội dung muốn tành hình<br/><br/> Ví dụ: Hôm nay <b>>đi chơi không<</b> trời đẹp quá.",
39+
input: "textarea",
40+
showCancelButton: true,
41+
}).then((result) => {
42+
if (result.isConfirmed) {
43+
let encoded = encode(result.value);
44+
Swal.fire({
45+
icon: "success",
46+
title: "Tạo tin tàng hình thành công",
47+
html: result.value + "<br/> Bạn hãy copy và sử dụng nhé",
48+
input: "textarea",
49+
inputValue: encoded,
50+
});
51+
}
52+
});
53+
}
54+
55+
function doDecode() {
56+
Swal.fire({
57+
icon: "question",
58+
title: "Nhập tin nhắn cần giải mã",
59+
input: "textarea",
60+
showCancelButton: true,
61+
}).then((result) => {
62+
if (result.isConfirmed) {
63+
let decoded = decode(result.value);
64+
if (decoded != result.value) {
65+
Swal.fire({
66+
icon: "success",
67+
title: "Kết quả giải mã",
68+
text: result.value,
69+
input: "textarea",
70+
inputValue: decoded,
71+
});
72+
} else {
73+
Swal.fire({
74+
icon: "info",
75+
title: "Tin nhắn này chưa được mã hoá",
76+
text: result.value,
77+
});
78+
}
79+
}
80+
});
81+
}
82+
},
83+
},
84+
};
85+
86+
const PADDING_START = "\u200c";
87+
const PADDING_END = "\u{e0061}";
88+
const CHARS = [
89+
// "\u200d",
90+
// "\u{e0061}",
91+
"\u{e0062}",
92+
"\u{e0063}",
93+
"\u{e0064}",
94+
"\u{e0065}",
95+
"\u{e0066}",
96+
"\u{e0067}",
97+
"\u{e0068}",
98+
"\u{e0069}",
99+
"\u{e006a}",
100+
"\u{e006b}",
101+
"\u{e006c}",
102+
"\u{e006d}",
103+
"\u{e006e}",
104+
"\u{e006f}",
105+
"\u{e0070}",
106+
"\u{e0071}",
107+
"\u{e0072}",
108+
"\u{e0073}",
109+
"\u{e0074}",
110+
"\u{e0075}",
111+
"\u{e0076}",
112+
"\u{e0077}",
113+
"\u{e0078}",
114+
"\u{e0079}",
115+
"\u{e007a}",
116+
"\u{e007f}",
117+
];
118+
export const shouldEncodePattern = / *>(.+?)< */;
119+
const encodedPattern = new RegExp(
120+
`${PADDING_START}([${CHARS.join("")}]+?)${PADDING_END}`
121+
);
122+
const CHARS_MAP = CHARS.reduce((curr, val, i) => {
123+
curr[val] = i;
124+
return curr;
125+
}, {});
126+
const lenCalc = (base, chars) => {
127+
var len = 0;
128+
var curr = 1;
129+
while (curr < chars) {
130+
curr *= base;
131+
len++;
132+
}
133+
return len;
134+
};
135+
const UNICODE_CHARS = 1114112;
136+
const BASE = CHARS.length;
137+
const LEN = lenCalc(BASE, UNICODE_CHARS);
138+
const charConvert = (char) => {
139+
let charCode = char.codePointAt(0);
140+
let arr = [];
141+
while (charCode > 0) {
142+
arr.push(charCode % BASE);
143+
charCode = ~~(charCode / BASE);
144+
}
145+
while (arr.length < LEN) {
146+
arr.push(0);
147+
}
148+
return arr.reverse();
149+
};
150+
const charEncode = (convertedChar) => {
151+
return convertedChar.reduce((curr, digit) => curr + CHARS[digit], "");
152+
};
153+
const _encode = (s) => {
154+
let converted = [];
155+
for (let c of s) {
156+
converted.push(charConvert(c));
157+
}
158+
let res = converted.map(charEncode);
159+
return PADDING_START + res.join("") + PADDING_END;
160+
};
161+
export const encode = (text) => {
162+
let matches = shouldEncodePattern.exec(text);
163+
if (!matches) return text;
164+
return text.replace(shouldEncodePattern, " " + _encode(matches[1]));
165+
};
166+
const decodeChar = (encodedChar) => {
167+
encodedChar = encodedChar.reverse();
168+
let curr = 1;
169+
let charCode = 0;
170+
for (let digit of encodedChar) {
171+
charCode += digit * curr;
172+
curr *= BASE;
173+
}
174+
return String.fromCodePoint(charCode);
175+
};
176+
const _decode = (s) => {
177+
s = encodedPattern.exec(s)[1];
178+
let curr = [];
179+
let res = "";
180+
for (let c of s) {
181+
curr.push(CHARS_MAP[c]);
182+
if (curr.length >= LEN) {
183+
res += decodeChar(curr);
184+
curr = [];
185+
}
186+
}
187+
return res;
188+
};
189+
export const decode = (text) => {
190+
if (!canDecode(text)) return text;
191+
return text.replace(encodedPattern, `>${_decode(text)}<`);
192+
};
193+
194+
const canDecode = (text) => {
195+
return encodedPattern.test(text);
196+
};
197+
const canEncode = (s) => {
198+
//console.log(s);
199+
return encodedPattern.exec(s);
200+
};

0 commit comments

Comments
 (0)