-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
insta_getFollowForOther.js
114 lines (101 loc) · 3.7 KB
/
insta_getFollowForOther.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import { UfsGlobal } from "./content-scripts/ufs_global.js";
export default {
icon: '<i class="fa-solid fa-user-secret fa-lg"></i>',
name: {
en: "Insta - Export all following/followers",
vi: "Insta - Tải tất cả following/follower",
},
description: {
en: "Know about your (or your friends's) following / followers on instagram. Export to json file",
vi: "Biết bạn bè của bạn (hoặc chính bạn) đang follow những ai / được ai follow trên instagram. Tải về file json",
},
whiteList: ["https://www.instagram.com/*"],
popupScript: {
onClick: async function () {
const { getUidFromUsername, getCrftoken } = await import(
"./insta_GLOBAL.js"
);
const { showLoading, runScriptInCurrentTab } = await import(
"./helpers/utils.js"
);
const { t } = await import("../popup/helpers/lang.js");
let username = prompt(t({ vi: "Nhập username", en: "Enter username" }));
if (!username) return;
const { closeLoading, setLoadingText } = showLoading(
t({ vi: "Đang tìm uid...", en: "Finding uid..." })
);
try {
let uid = await getUidFromUsername(username);
if (!uid)
throw new Error(
t({
vi: "Không tìm thấy uid cho user " + username,
en: "Can't find uid for " + username,
})
);
setLoadingText(t({ vi: "Đang tìm token...", en: "Finding token..." }));
let csrftoken = await runScriptInCurrentTab(getCrftoken);
if (!csrftoken) throw new Error("Can't get csrftoken");
let type = prompt(
t({
vi: "Bạn muốn tải gì?\n1: followers (được ai follow)\n2: following (đang follow ai)",
en: "Which one do you want to download?\n1: followers\n2: following",
}),
1
);
if (!type) return;
let typename = type == 1 ? "followers" : "following";
let limit = prompt(
t({
vi: "Tải tối đa bao nhiêu kết quả? (nhập 0 để tải hết)",
en: "How many results do you want to download? (enter 0 to download all)",
}),
0
);
if (limit == null) return;
runScriptInCurrentTab(
async ({ username, typename, uid, csrftoken, limit }) => {
let scriptPath = await UfsGlobal.Extension.getURL(
"/scripts/insta_GLOBAL.js"
);
const { getAllFollow } = await import(scriptPath);
const notify = UfsGlobal.DOM.notify({
msg: "Đang tải " + typename + " của " + username,
duration: 99999999,
});
try {
let data = await getAllFollow({
type: typename,
uid,
csrftoken,
limit,
progressCallback: ({ total, current, data }) => {
console.log(data);
notify.setText(
`Đang tải ${typename} của ${username}: ${current}/${total}...`
);
},
});
console.log(data);
if (!data?.length) throw new Error("No Data");
UfsGlobal.Utils.downloadData(
JSON.stringify(data, null, 4),
`${username}_${typename}.json`
);
} catch (e) {
console.error(e);
alert("ERROR " + e);
} finally {
notify.remove();
}
},
[{ username, typename, uid, csrftoken, limit }]
);
} catch (e) {
alert("ERROR " + e);
} finally {
closeLoading();
}
},
},
};