Skip to content

Commit 6f6c512

Browse files
committed
add shrinkearn.com
1 parent 1310717 commit 6f6c512

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

scripts/unshorten.js

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,19 @@ export default {
4444
},
4545
};
4646

47-
// https://linkunshorten.com/
48-
const linkunshorten = {
49-
async getLongUrl(shortURL) {
50-
let res = await fetch(
51-
"https://linkunshorten.com/api/link?url=" + shortURL
52-
);
53-
let text = await res.text();
54-
return JSON.parse(text || "");
47+
const customs = [
48+
{
49+
name: "shrinkearn.com",
50+
fn: (url) => {
51+
let u = new URL(url);
52+
let host = u.hostname;
53+
let url_param = u.searchParams.get("url");
54+
if (host == "shrinkearn.com" && url_param) {
55+
return atob(url_param);
56+
}
57+
},
5558
},
56-
};
59+
];
5760

5861
let short_url = prompt("Nhập URL đã rút gọn: ");
5962
if (short_url) {
@@ -64,24 +67,30 @@ export default {
6467
// "&source=chromeextension"
6568
// );
6669

67-
const { closeLoading, setLoadingText } = showLoading("Đang lấy token...");
70+
const { closeLoading, setLoadingText } = showLoading("Đang chuẩn bị...");
6871
try {
6972
let long_url;
70-
try {
71-
setLoadingText(
72-
"Đang giải mã link rút gọn...<br/>Sử dụng linkunshorten.com"
73-
);
74-
long_url = await linkunshorten.getLongUrl(short_url);
75-
if (long_url == short_url) throw Error();
76-
} catch (e) {
73+
for (let c of customs) {
74+
try {
75+
setLoadingText(
76+
"Đang giải mã link rút gọn...<br/>Sử dụng " + c.name
77+
);
78+
long_url = await c.fn(short_url);
79+
if (long_url) break;
80+
} catch (e) {
81+
console.log(e);
82+
}
83+
}
84+
85+
if (!long_url) {
7786
setLoadingText(
78-
"Đang giải mã link rút gọn...<br/>Sử dụng unshorten.it"
87+
"Đang giải mã link rút gọn...<br/>Sử dụng unshorten.com"
7988
);
8089
long_url = await unshortenIt.getLongUrl(short_url);
8190
}
82-
long_url
83-
? prompt("Link gốc của " + short_url, long_url)
84-
: alert("Không tìm thấy link gốc");
91+
if (!long_url || long_url == short_url)
92+
alert("Không tìm thấy link gốc");
93+
else prompt("Link gốc của " + short_url, long_url);
8594
} catch (e) {
8695
prompt(
8796
"Lỗi: " + e + "\n\nBạn có thể mở trang web bên dưới để thử lại:",

working_note.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# WORKING NOTES
22

3-
## 29/03/2024 - 16/04/2024
3+
## 29/03/2024 - 22/04/2024
44

55
- [ ] fb_invisible_message có vẻ không hoạt động
66

0 commit comments

Comments
 (0)