MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / main

Function main

scripts/fb_autoRemoveSpamPostGroup_main.js:20–80  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18}
19
20async function main() {
21 initCacheInput(waitMinInp, "wait-min");
22 initCacheInput(waitMaxInp, "wait-max");
23 initCacheInput(inputMaxPosts, "max-posts");
24
25 const tab = await getCurrentTab();
26
27 if (!tab.url.includes("groups") || !tab.url.includes("spam")) {
28 return prompt(
29 "\n\nBạn cần mở trang duyệt bài spam của group trước.\n\nLink hiện tại: " +
30 tab.url +
31 "\n\n\nLink đúng ví dụ:",
32 "https://www.facebook.com/groups/gamecode/spam"
33 );
34 }
35
36 startBtn.addEventListener("click", async () => {
37 const state = await getCurrentState(tab);
38 if (state?.running) {
39 return stop(tab);
40 }
41
42 let action = radioAction[0].checked ? 1 : 2;
43 let maxPosts = parseInt(inputMaxPosts.value);
44 let waitMin = parseInt(waitMinInp.value) * 1000;
45 let waitMax = parseInt(waitMaxInp.value) * 1000;
46
47 if (waitMin > waitMax) {
48 return alert(
49 "Thời gian chờ không hợp lệ\nBên trái phải bé hơn hoặc bằng bên phải"
50 );
51 }
52
53 runScriptInTab({
54 target: { tabId: tab.id },
55 func: start,
56 args: [action, maxPosts, waitMin, waitMax],
57 });
58 });
59
60 // check is running
61 (async function checkIsRunning() {
62 const state = await getCurrentState(tab);
63 const { running, nextExecuteTime, count, action } = state || {};
64 if (running) {
65 startBtn.innerHTML =
66 "Đang " +
67 (action === 1 ? "đăng" : "từ chối") +
68 "... " +
69 count +
70 " bài (chờ " +
71 renderTime(nextExecuteTime - Date.now(), 0) +
72 ")<br/>(<i>Bấm để dừng</i>)";
73 startBtn.classList.add("running");
74 } else {
75 startBtn.innerHTML = "Bắt đầu";
76 startBtn.classList.remove("running");
77 }

Callers 2

startFunction · 0.70

Calls 11

initCacheInputFunction · 0.85
getCurrentStateFunction · 0.85
stopFunction · 0.85
renderTimeFunction · 0.85
ranIntFunction · 0.85
clickMethod · 0.80
getCurrentTabFunction · 0.70
runScriptInTabFunction · 0.70
sleepFunction · 0.70
addMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected