Skip to content

Commit a372245

Browse files
committed
fix fb token
1 parent 0b9d426 commit a372245

15 files changed

+234
-75
lines changed

popup/tabs.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ const tabs = [
7575
createTitle("--- UI ---", "--- Giao diện ---"),
7676
s.fb_toggleLight,
7777
createTitle("--- Access Token ---", "--- Access Token ---"),
78+
s.fb_checkToken,
7879
s.fb_getTokenFfb,
79-
s.fb_getTokenEAAG,
80-
s.fb_getTokenBusiness,
80+
s.fb_getTokenBussinessLocation,
81+
s.fb_getTokenBusinessStudio,
82+
s.fb_getTokenCampaigns,
8183
s.fb_getTokenFacebook,
8284
s.fb_getTokenMFacebook,
8385
s.fb_getTokenLocmai,

scripts/fb_checkToken.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export default {
2+
icon: `<i class="fa-regular fa-square-check"></i>`,
3+
name: {
4+
en: "Check fb access token",
5+
vi: "Kiểm tra fb access token",
6+
},
7+
description: {
8+
en: "Check type, permissions, created date, expired date, ...",
9+
vi: "Kiểm tra loại, quyền, ngày tạo, ngày hết hạn, ...",
10+
},
11+
runInExtensionContext: true,
12+
13+
func: function () {
14+
let token = window.prompt(
15+
"Enter accesstoken want to check\nNhập access token muốn kiểm tra:",
16+
""
17+
);
18+
if (token) {
19+
window.open(
20+
"https://developers.facebook.com/tools/debug/accesstoken/?access_token=" +
21+
token
22+
);
23+
}
24+
},
25+
};

scripts/fb_downloadAlbumMedia.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ export default {
77
en: "Download photo/video links from album",
88
vi: "Tải về danh sách link ảnh/video",
99
},
10-
blackList: [],
11-
whiteList: ["*://www.facebook.com"],
10+
runInExtensionContext: true,
1211

1312
func: function () {
1413
const accessToken = prompt("Enter access token:", "");

scripts/fb_getAvatarFromUid.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ export default {
77
en: "Get avatar from list user ids",
88
vi: "Tải danh sách avatar từ danh sách user id",
99
},
10-
blackList: [],
11-
whiteList: ["*://www.facebook.com"],
10+
runInExtensionContext: true,
1211

1312
func: async function () {
1413
let accessToken = prompt("Nhập facebook access token: ");
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
export default {
22
icon: `<i class="fa-solid fa-key"></i>`,
33
name: {
4-
en: "Get fb Token (business.facebook.com)",
5-
vi: "Lấy fb token (business.facebook.com)",
4+
en: "Get fb token EAAc (studio)",
5+
vi: "Lấy fb token EAAc (studio)",
66
},
77
description: {
88
en: "Get facebook access token from business.facebook.com",
99
vi: "Lấy facebook access token từ trang business.facebook.com",
1010
},
1111
blackList: [],
12-
whiteList: ["*://business.facebook.com"],
12+
// whiteList: ["*://business.facebook.com"],
13+
runInExtensionContext: true,
1314

1415
func: function () {
1516
// old - FAILED
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
export default {
2+
icon: `<i class="fa-solid fa-key"></i>`,
3+
name: {
4+
en: "Get fb token EAAG (business_locations)",
5+
vi: "Lấy fb token EAAG (business_locations)",
6+
},
7+
description: {
8+
en: "Get fb token EAAG from business.facebook.com",
9+
vi: "Lấy fb token EAAG từ business.facebook.com",
10+
},
11+
blackList: [],
12+
runInExtensionContext: true,
13+
14+
func: function () {
15+
// Get token using cookies https://github.com/dz-id/fb_get_token_from_cookie/blob/main/main.py
16+
17+
fetch("https://business.facebook.com/business_locations")
18+
.then((res) => res.text())
19+
.then((htmlText) => {
20+
let regex = htmlText.match(/(EAAG\w+)/);
21+
if (null !== regex) {
22+
let accesstoken = regex[1];
23+
prompt("Access Token: ", accesstoken);
24+
} else {
25+
prompt(
26+
"Không thấy token. Hãy chắc rằng bạn đã đăng nhập vào",
27+
"https://business.facebook.com/business_locations"
28+
);
29+
}
30+
})
31+
.catch((e) => alert("Error: " + e));
32+
},
33+
};
34+
35+
// {
36+
// method: "GET",
37+
// credentials: "include",
38+
// headers: {
39+
// "user-agent":
40+
// "Mozilla/5.0 (Linux; Android 8.1.0; MI 8 Build/OPM1.171019.011) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.86 Mobile Safari/537.36", // don't change this user agent.
41+
// referer: "https://www.facebook.com/",
42+
// host: "business.facebook.com",
43+
// origin: "https://business.facebook.com",
44+
// "upgrade-insecure-requests": "1",
45+
// "accept-language": "id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7",
46+
// "cache-control": "max-age=0",
47+
// accept:
48+
// "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
49+
// "content-type": "text/html; charset=utf-8",
50+
// },
51+
// }
52+
53+
// if (-1 == htmlText.search("EAA")) {
54+
// alert("Token not found");
55+
// return;
56+
// }
57+
// var o = htmlText.match(/EAAGNO.*?\"/);
58+
// prompt("Token", o[0] ? o[0].replace(/\W/g, "") : "");

scripts/fb_getTokenCampaigns.js

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
export default {
2+
icon: `<i class="fa-solid fa-key"></i>`,
3+
name: {
4+
en: "Get fb token EAAB (campaigns)",
5+
vi: "Lấy fb token EAAB (campaigns)",
6+
},
7+
description: {
8+
en: "Get fb token EAAG from www.facebook.com campaigns",
9+
vi: "Lấy fb token EAAG từ www.facebook.com campaigns",
10+
},
11+
runInExtensionContext: true,
12+
13+
func: function () {
14+
// Source code extracted from https://chrome.google.com/webstore/detail/get-token-cookie/naciaagbkifhpnoodlkhbejjldaiffcm/related
15+
16+
async function getToken() {
17+
try {
18+
let res = await fetch(
19+
"https://www.facebook.com/adsmanager/manage/campaigns"
20+
);
21+
let htmlText = await res.text();
22+
if (-1 != htmlText.search("EAA")) {
23+
var regex_result = htmlText.match(/EAAB.*?\"/),
24+
token = regex_result[0] ? regex_result[0].replace(/\W/g, "") : "";
25+
return token;
26+
}
27+
for (
28+
var regex_value, act, regex = /campaigns\?act=(.*?)&/g;
29+
null !== (regex_value = regex.exec(htmlText));
30+
31+
)
32+
regex_value.index === regex.lastIndex && regex.lastIndex++,
33+
regex_value.forEach(function (_value, _index) {
34+
1 == _index && (act = _value);
35+
});
36+
if (act) {
37+
let res = await fetch(
38+
`https://www.facebook.com/adsmanager/manage/campaigns?act=${act}&nav_source=no_referrer`
39+
);
40+
let htmlText = await res.text();
41+
if (-1 == htmlText.search("EAA")) return resolve("");
42+
var regex_result = htmlText.match(/EAAB.*?\"/),
43+
token = regex_result[0] ? regex_result[0].replace(/\W/g, "") : "";
44+
return token;
45+
}
46+
} catch (e) {
47+
alert("Error: " + e);
48+
}
49+
return "";
50+
}
51+
52+
(async () => {
53+
let token = await getToken();
54+
if (token) {
55+
window.prompt("Access token: ", token);
56+
} else {
57+
alert("Không tìm thấy access token");
58+
}
59+
})();
60+
},
61+
};
62+
63+
function backup() {
64+
(() => {
65+
var GetToken = (callback) => {
66+
var fb_dtsg = require("DTSG_ASYNC").getToken();
67+
var http = new XMLHttpRequest();
68+
var data = new FormData();
69+
data.append("fb_dtsg", fb_dtsg);
70+
data.append("app_id", "124024574287414");
71+
data.append("redirect_uri", "fbconnect://success");
72+
data.append("display", "popup");
73+
data.append("ref", "Default");
74+
data.append("return_format", "access_token");
75+
data.append("sso_device", "ios");
76+
data.append("__CONFIRM__", "1");
77+
http.open("POST", "/v1.0/dialog/oauth/confirm");
78+
http.send(data);
79+
http.onreadystatechange = function () {
80+
console.log(http.responseText);
81+
if (http.readyState == 4 && http.status == 200)
82+
callback(http.responseText.match(/access_token=(.*?)&/)?.[1]);
83+
};
84+
};
85+
GetToken(console.log);
86+
})();
87+
88+
var uid = document.cookie.match(/c_user=(\d+)/)[1],
89+
dtsg = require("DTSG_ASYNC").getToken(),
90+
http = new XMLHttpRequest(),
91+
url = "//www.facebook.com/v1.0/dialog/oauth/confirm",
92+
params =
93+
"fb_dtsg=" +
94+
dtsg +
95+
"&app_id=165907476854626&redirect_uri=fbconnect%3A%2F%2Fsuccess&display=page&access_token=&from_post=1&return_format=access_token&domain=&sso_device=ios&__CONFIRM__=1&__user=" +
96+
uid;
97+
http.open("POST", url, !0),
98+
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"),
99+
(http.onreadystatechange = function () {
100+
if (4 == http.readyState && 200 == http.status) {
101+
var a = http.responseText.match(/access_token=(.*)(?=&expires_in)/);
102+
(a = a
103+
? a[1]
104+
: "Failed to get Access token make sure you authorized the HTC sense app"),
105+
prompt("Token", a);
106+
}
107+
}),
108+
http.send(params);
109+
}

scripts/fb_getTokenEAAG.js

Lines changed: 0 additions & 46 deletions
This file was deleted.

scripts/fb_getTokenFacebook.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export default {
22
icon: `<i class="fa-solid fa-key"></i>`,
33
name: {
4-
en: "Get fb Token (www.facebook.com)",
5-
vi: "Lấy fb Token (www.facebook.com)",
4+
en: "Get fb token EAAB (instagram)",
5+
vi: "Lấy fb token EAAB (instagram)",
66
},
77
description: {
88
en: "Get facebook access token from www.facebook.com",

scripts/fb_getTokenLocmai.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
2-
icon: "",
2+
icon: `<i class="fa-solid fa-key"></i>`,
33
name: {
44
en: "Get fb token (locmai)",
55
vi: "Lấy fb token (locmai)",

0 commit comments

Comments
 (0)