forked from lovmoon3k/useful-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfb_getTokenFacebook.js
46 lines (44 loc) · 1.47 KB
/
fb_getTokenFacebook.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 (www.facebook.com)",
vi: "Lấy fb Token (www.facebook.com)",
},
description: {
en: "Get facebook access token from www.facebook.com",
vi: "Lấy facebook access token từ trang www.facebook.com",
},
blackList: [],
whiteList: ["*://www.facebook.com"],
func: function () {
var uid = /(?<=c_user=)(\d+)/.exec(document.cookie)[0],
dtsg =
require("DTSGInitialData").token ||
document.querySelector('[name="fb_dtsg"]').value,
http = new XMLHttpRequest(),
url = "//www.facebook.com/v1.0/dialog/oauth/confirm",
params =
"fb_dtsg=" +
dtsg +
"&app_id=124024574287414&redirect_uri=fbconnect%3A%2F%2Fsuccess&display=page&access_token=&from_post=1&return_format=access_token&domain=&sso_device=ios&_CONFIRM=1&_user=" +
uid;
http.open("POST", url, !0),
http.setRequestHeader(
"Content-type",
"application/x-www-form-urlencoded"
),
(http.onreadystatechange = function () {
if (4 == http.readyState && 200 == http.status) {
var a = http.responseText.match(/(?<=access_token=)(.*?)(?=\&)/);
console.log(http.responseText);
if (a && a[0]) {
prompt("Token", a[0]);
} else {
alert("Failed to Get Access Token.");
}
}
}),
http.send(params);
},
};
export function getTokenFacebook() {}