Skip to content

Commit 619c5d7

Browse files
committed
fix bypass group
1 parent ccd2fcd commit 619c5d7

File tree

3 files changed

+46
-10
lines changed

3 files changed

+46
-10
lines changed

scripts/backup/ext/fb-auto-invite-share/background.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { sharePostToGroup } from "./popup/helpers/facebook.js";
2-
import { ranInt } from "./popup/helpers/utils.js";
2+
import { randInt } from "./popup/helpers/utils.js";
33

44
console.log("background");
55

@@ -88,7 +88,8 @@ setInterval(() => {
8888
`DONE: share ${job.postUrl} to ${job.groups.length} groups`
8989
);
9090
} else {
91-
job.nextShareTime = Date.now() + ranInt(job.waitMin, job.waitMax);
91+
job.nextShareTime =
92+
Date.now() + randInt(job.waitMin, job.waitMax);
9293
}
9394
job.sharing = false;
9495
});

scripts/backup/ext/fb-auto-invite-share/popup/auto_share_to_group/main.js

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { getPostIdFromUrl, getUidFromUrl } from "../helpers/facebook.js";
1+
import {
2+
getEntityAbout,
3+
getPostIdFromUrl,
4+
getUidFromUrl,
5+
TargetType,
6+
} from "../helpers/facebook.js";
27

38
const runningDiv = document.getElementById("running");
49
const inputPostURL = document.getElementById("inputPostURL");
@@ -59,15 +64,45 @@ async function main() {
5964
}
6065

6166
const groupUrls = inputGroups.value.split("\n");
67+
const failedGroups = [];
6268
for (let i = 0; i < groupUrls.length; ++i) {
63-
startBtn.innerHTML =
64-
"Đang kiểm tra các group... " + (i + 1) + "/" + groupUrls.length;
65-
const groupId = await getUidFromUrl(groupUrls[i]);
66-
console.log(groupId);
67-
if (!groupId) throw Error("Không thấy id group của " + groupUrls[i]);
69+
try {
70+
startBtn.innerHTML =
71+
"Đang kiểm tra các group... " + (i + 1) + "/" + groupUrls.length;
72+
const groupId = await getUidFromUrl(groupUrls[i]);
73+
const groupInfo = await getEntityAbout(groupId);
74+
console.log(groupId, groupInfo);
75+
if (groupInfo?.type !== TargetType.Group)
76+
failedGroups.push({
77+
url: groupUrls[i],
78+
info: groupInfo,
79+
error: "Không phải là group: " + groupInfo?.type,
80+
});
81+
} catch (e) {
82+
failedGroups.push({
83+
url: groupUrls[i],
84+
error: e,
85+
});
86+
}
6887
}
88+
if (!failedGroups.length) addJob();
89+
else if (
90+
confirm(
91+
`Có ${failedGroups.length} group không hợp lệ. Bạn có muốn tiếp tục không?\n\n` +
92+
failedGroups
93+
.map((_, i) => `+ ${_.url} ${_.info?.name || ""}: ${_.error}`)
94+
.join("\n") +
95+
"\n\n> Bấm Huỷ/Cancel để nhập lại\n> Bấm Ok để bỏ qua group lỗi"
96+
)
97+
) {
98+
const groupsLeft = groupUrls.filter(
99+
(url) => !failedGroups.map((_) => _.url).includes(url)
100+
);
101+
inputGroups.value = groupsLeft.join("\n");
69102

70-
addJob();
103+
if (groupsLeft.length) addJob();
104+
else alert("Không còn group để chia sẻ");
105+
}
71106
} catch (e) {
72107
alert("LỖI: " + e.message);
73108
} finally {

scripts/backup/ext/fb-auto-invite-share/popup/helpers/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function sleep(time) {
44
});
55
}
66

7-
export function ranInt(min, max) {
7+
export function randInt(min, max) {
88
return Math.floor(Math.random() * (max - min) + min);
99
}
1010

0 commit comments

Comments
 (0)