forked from lovmoon3k/useful-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfb_getTokenBusiness.js
46 lines (44 loc) · 1.27 KB
/
fb_getTokenBusiness.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
export default {
icon: `<i class="fa-solid fa-key"></i>`,
name: {
en: "Get fb Token (business.facebook.com)",
vi: "Lấy fb token (business.facebook.com)",
},
description: {
en: "Get facebook access token from business.facebook.com",
vi: "Lấy facebook access token từ trang business.facebook.com",
},
blackList: [],
whiteList: ["*://business.facebook.com"],
func: function () {
// old - FAILED
// try {
// const accessToken =
// "EAA" + /(?<=EAA)(.*?)(?=\")/.exec(document.body.textContent)[0];
// window.prompt("Access Token của bạn:", accessToken);
// } catch (e) {
// alert("LỖI: " + e.message);
// }
fetch("https://business.facebook.com/creatorstudio/home", {
method: "GET",
credentials: "include",
})
.then(function (res) {
return res.text();
})
.then(function (htmlText) {
let regex = htmlText.match(
/MediaManagerStatics",\[\],{"accessToken":"(.+?)"/
);
if (null !== regex) {
let accesstoken = regex[1];
prompt("Access Token: ", accesstoken);
} else {
alert("Token not found");
}
})
.catch(function (e) {
alert("ERROR:" + JSON.stringify(e));
});
},
};