Skip to content

Commit

Permalink
fix TWL2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
m1m1s1ku committed May 11, 2023
1 parent 1464dc0 commit 055f752
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ThiWeb Crypt-Decrypt",
"version": "2.1.1",
"version": "2.1.2",
"manifest_version": 3,
"description": "Crypt / Auto-decrypt Links on ThiWeb",
"homepage_url": "https://www.thiweb.com",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "thiweb-crypt-decrypt-ts",
"version": "2.1.1",
"version": "2.1.2",
"type": "module",
"scripts": {
"build": "tsc && vite build",
Expand Down
21 changes: 18 additions & 3 deletions src/inject/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ function hexToText(hex: string): string {
const charCode = parseInt(hexByte, 16);
result += String.fromCharCode(charCode);
}
return decodeURIComponent(escape(result));
}
const escaped = escape(result);
try {
return decodeURIComponent(escaped);
} catch (err) {
return unescape(escaped);
}
}

function decodeTWL(str: string): string {
str = str.replace(/[\r\n\s]+/g, "");
Expand All @@ -24,7 +29,17 @@ function decodeTWL(str: string): string {
let hex = match[2];

if (version == "TWL2.0") {
hex = hex.replace(/A0D0/g, "AD");
let patched = "";
for(let i = 0; i < str.length; i += 2) {
const c = str.substring(i, i+2);
if(c == "AD") {
patched += "A0D0";
} else {
patched += c;
}
}
hex = patched;
// hex = hex.replace(/A0D0/g, "AD");
}

return hexToText(reverseString(hex));
Expand Down

0 comments on commit 055f752

Please sign in to comment.