|
1 | 1 | export default { |
2 | | - icon: `<i class="fa-solid fa-arrow-up-right-from-square"></i>`, |
| 2 | + icon: "https://ffb.vn/assets/img/illustrations/favicon.png", |
3 | 3 | name: { |
4 | | - en: "Get fb token full permission (ffb.vn)", |
5 | | - vi: "Lấy token fb đủ quyền (ffb.vn)", |
| 4 | + en: "Get fb token from cookie (ffb.vn)", |
| 5 | + vi: "Lấy fb token từ cookie (ffb.vn)", |
6 | 6 | }, |
7 | 7 | description: { |
8 | | - en: "WARNING: I do not own this website. Be careful when use!", |
9 | | - vi: "CẢNH BÁO: Không phải trang web của mình. Cẩn thận khi sử dụng!", |
| 8 | + en: "Post your fb cookie to ffb.vn API", |
| 9 | + vi: "Gửi cookie fb lên API của ffb.vn", |
10 | 10 | }, |
11 | 11 | blackList: [], |
12 | 12 | whiteList: [], |
| 13 | + runInExtensionContext: true, |
13 | 14 |
|
14 | 15 | func: function () { |
15 | | - window.open("https://ffb.vn/get-token"); |
| 16 | + async function getCookiesInExtensionContext(domain) { |
| 17 | + let cookies = await chrome.cookies.getAll({ domain }); |
| 18 | + return cookies.map((_) => _.name + "=" + decodeURI(_.value)).join(";"); |
| 19 | + } |
| 20 | + |
| 21 | + (async () => { |
| 22 | + let cookie = await getCookiesInExtensionContext("facebook.com"); |
| 23 | + if (!cookie) { |
| 24 | + alert("Không thấy cookie. Hãy chắc rằng bạn đã đăng nhập facebook!"); |
| 25 | + } else { |
| 26 | + //prettier-ignore |
| 27 | + let types = ["eaaq","eaag","eaab","eaas","eaai","eaaa","Mở trang ffb.vn",]; |
| 28 | + let typeIndex = prompt( |
| 29 | + "[Lưu ý]\n" + |
| 30 | + "+ Sẽ gửi cookie facebook của bạn lên ffb.vn\n" + |
| 31 | + "+ Mình không đảm bảo an toàn cho cookie của bạn\n" + |
| 32 | + "+ Ấn Cancel ngay nếu muốn huỷ\n\n" + |
| 33 | + "Chọn loại token muốn lấy:\n" + |
| 34 | + types.map((_, i) => ` ${i}: ${_.toUpperCase()}`).join("\n"), |
| 35 | + 0 |
| 36 | + ); |
| 37 | + |
| 38 | + if (typeIndex == null) return; |
| 39 | + if (typeIndex < 0 || typeIndex >= types.length) { |
| 40 | + alert( |
| 41 | + "Invalid type. Please try again\nLựa chọn không hợp lệ. Vui lòng thử lại" |
| 42 | + ); |
| 43 | + return; |
| 44 | + } |
| 45 | + if (typeIndex == types.length - 1) { |
| 46 | + window.open("https://ffb.vn/get-token"); |
| 47 | + return; |
| 48 | + } |
| 49 | + |
| 50 | + const formData = new FormData(); |
| 51 | + formData.append("cookie", cookie); |
| 52 | + formData.append("type", types[typeIndex]); |
| 53 | + |
| 54 | + let res = await fetch("https://ffb.vn/api/tool/cookie2token", { |
| 55 | + method: "POST", |
| 56 | + body: formData, |
| 57 | + }); |
| 58 | + let json = await res.json(); |
| 59 | + if (json.error) { |
| 60 | + alert("ERROR: " + json.msg); |
| 61 | + } else { |
| 62 | + prompt("Access token", json.token); |
| 63 | + } |
| 64 | + } |
| 65 | + })(); |
16 | 66 | }, |
17 | 67 | }; |
0 commit comments